Tuesday, November 17, 2009

Reset admin / host password for dotnetnuke site

Declare @UserName NVarChar(255)
Declare @NewPassword NVarChar(255)
Declare @PasswordSalt NVarChar(128)
Declare @Application NVarChar(255)

-- Enter the user name and new password between ''
-- do not leave any spaces unless intended to do so.
-- Edit only between single quote characters
Set @UserName = 'host' -- This is a default DNN admin user; the default host user is 'host'
Set @NewPassword = 'password' -- Your new password

SET @APPLICATION = (SELECT [APPLICATIONNAME] FROM ASPNET_USERS U,ASPNET_APPLICATIONS A WHERE U.APPLICATIONID = A.APPLICATIONID AND USERNAME=@USERNAME)
Set @PasswordSalt = (SELECT PasswordSalt FROM aspnet_Membership WHERE UserID IN (SELECT UserID FROM aspnet_Users WHERE UserName=@UserName))

Exec dbo.aspnet_Membership_ResetPassword @Application, @UserName, @NewPassword, 10, 10, @PasswordSalt, -5