DNN – Regain User Access

| |

If you have ever been locked out of a DNN site you maintain (must have SQL access) this solution will help.

NOTE: If you don’t have SMTP settings configured this process will not help

First find your “Portals” table and update “UserRegistration” = 2
Note: In the example below I have “dnn” as my prefix, you may have something different

--Update dnn_Portals SET UserRegistration = 0 -- Turn Off Registration
--Update dnn_Portals SET UserRegistration = 1 -- Turn On Private Registration, make sure SMTP settings are configured correctly
Update dnn_Portals SET UserRegistration = 2 -- Turn On Public Registration
--Update dnn_Portals SET UserRegistration = 3 -- Turn On Verified Registration, make sure SMTP settings are configured correctly

Go to your site and register a new account

Example:
david account password is unknown, david1 account is the new account and you know the password

DECLARE @DNNOriginalUser VARCHAR(MAX)
	,@DNNNewUser VARCHAR(MAX)

SET @DNNOriginalUser = 'david'
SET @DNNNewUser = 'david1'

SELECT aU.[UserId]
	,[UserName]
	,[Password]
	,[PasswordSalt]
	,[LastActivityDate]
FROM [aspnet_Users] aU
INNER JOIN [aspnet_Membership] aM ON aU.UserId = aM.UserId
WHERE [UserName] = @DNNOriginalUser
	OR [UserName] = @DNNNewUser

Run this script below and you should be able to log in again.
NOTE: As always run a backup of your database before you try this script.

DECLARE @DNNOriginalUser VARCHAR(MAX)
	,@DNNNewUser VARCHAR(MAX)

SET @DNNOriginalUser = 'david'
SET @DNNNewUser = 'david1'

UPDATE aspnet_Membership
SET [Password] = (
		SELECT aM.[Password]
		FROM aspnet_Membership aM
		INNER JOIN [aspnet_Users] aU ON aU.UserId = aM.UserId
		WHERE [UserName] = @DNNNewUser
		)
	,[PasswordSalt] = (
		SELECT aM.[PasswordSalt]
		FROM aspnet_Membership aM
		INNER JOIN [aspnet_Users] aU ON aU.UserId = aM.UserId
		WHERE [UserName] = @DNNNewUser
		)
FROM aspnet_Membership
INNER JOIN [aspnet_Users] ON [aspnet_Users].UserId = aspnet_Membership.UserId
WHERE [aspnet_Users].UserName = @DNNOriginalUser

Reference: http://www.deutschnetnuke.de/tabid/183/Default.aspx

Originally Posted on March 25, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.