Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Programmatically reset passwordProgrammatically reset password
Previous
 
Next
New Post
3/5/2008 1:49 PM
 

Hi all!

I've been searching around for some code examples on how to reset a password for a user within a custom module, and have come up with nothing.  I have code that creates users, edits user info and profile info, creates the initial password, etc..  However, I can't find a way to change a user password as you can in the 'manage password' dnn menu.  I'm using DNN 4.7 (or was it 4.6..., if it matters I'll find out for sure)

Here's the code I'm using that doesn't work (though it doesn't return false as I'd expect):

string oldPassword = DotNetNuke.Entities.Users.UserController.ResetPassword(userInfo, "");
            if (!DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, password))
            {
                OnError("There was an error changing the password!");
            }

As you can see, I'm trying to get the old password by using ResetPassword on the userInfo.  The next line doesn't appear to work, however (though it returns true....)

Currently I have a filled UserInfo object of the user whose password I'm trying to reset, but I don't have their actual password.  I have a routine that generates a random password, or alternatively I'd like the user of my module to be able to type in a temporary password that the user must reset when they log in.   If someone can provide me with the code, or the function that I'll need to use, I'd be appreciative.  Thanks!

PS.  How do I correctly submit formatted code on this form?  I don't see a button or explaination, though I could be blind as a bat!  Thanks!

 
New Post
3/5/2008 11:37 PM
 

Hi Brad,

you can get the actual user password(old password) using:

oldPassword=UserController.GetPassword(objUserInfo, passwordAnswer)

BR

Jutta

 
New Post
3/6/2008 8:09 AM
 

Jutta,

I"ll swap out the above method witht the reset password line in mine and see what happens!

 
New Post
6/17/2011 1:42 PM
 
will GetPassword() work if the password is hashed?
 
New Post
6/20/2011 5:49 AM
 
You can try:
create 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))



declare @RetVal as int

Exec @RetVal = dbo.aspnet_Membership_ResetPassword @ApplicationName, @UserName, @NewPassword, 10, 10, @PasswordSalt, -5

return @RetVal

end

I got it from http://www.devprise.com/2006/09/26/how-to-reset-a-dnn-password-at-the-database/
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Programmatically reset passwordProgrammatically reset password


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out