How to reset a DNN password at the Database

By Tony - Last updated: Tuesday, September 26, 2006 - Save & Share - 2 Comments

If your DotNetNuke passwords all of a sudden stop working (like due to a failed upgrade), have no fear you can reset them at the database! This is not a hack, it uses the official aspnet Password Reset.

  • Open SQL Query Analyzer – Connect to your dotNetNuke database
  • Paste the following Stored Procedure code into the window, this will create a stored procedure for later use called uap_ResetPassword. This should survive DNN upgrades because we are predicating the stored procedure name with uap_
  • create procedure uap_ResetPassword
      @UserName NVarChar(255),
      @NewPassword NVarChar(255)
    as
    begin
    	Declare @PasswordSalt NVarChar(128)
    	Declare @Application NVarChar(255)
    
    	Set @Application = (SELECT [ApplicationID] FROM aspnet_Users WHERE 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
    end
  • Now you can reset your DotNetNuke passwords by simply opening up SQL Query Analyzer, connecting to your dotNetNuke database, then typing uap_ResetPassword ‘username’, ‘newpassword’
  • Posted in Databases, Web • • Top Of Page

    2 Responses to “How to reset a DNN password at the Database”

    Comment from Hector Correa
    Time November 25, 2006 at 10:55 pm

    Here is an updated version that passes the ApplicationName (rather than the ApplicationID) to the aspnet_Membership_ResetPassword stored procedure. I am also returning the return value to catch possible errors while execurting aspnet_Membership_ResetPassword.

    ALTER procedure [dbo].[uap_ResetPassword]
    @UserName NVarChar(255),
    @NewPassword NVarChar(255)
    as
    begin
    Declare @PasswordSalt NVarChar(128)
    Declare @ApplicationID NVarChar(255)
    Declare @ApplicationName NVarChar(255)

    Set @ApplicationID = (SELECT [ApplicationID] FROM aspnet_Users WHERE UserName=@UserName)
    Set @ApplicationName = (SELECT [ApplicationName] FROM aspnet_Applications WHERE ApplicationID=@ApplicationID)
    Set @PasswordSalt = (SELECT PasswordSalt FROM aspnet_Membership WHERE UserID IN (SELECT UserID FROM aspnet_Users WHERE UserName=@UserName))

    –select @ApplicationID, @ApplicationName
    declare @RetVal as int
    Exec @RetVal = dbo.aspnet_Membership_ResetPassword @ApplicationName, @UserName, @NewPassword, 10, 10, @PasswordSalt, -5
    return @RetVal

    end

    Comment from Mike
    Time April 23, 2007 at 4:51 am

    Thanks, this made my day. I have had 2 DNN 4.5 installs that had this happen. Thank you for sharing your wisdom.

    Write a comment

    You need to login to post comments!