Link to home
Start Free TrialLog in
Avatar of Shade22
Shade22Flag for United States of America

asked on

ASP.NET - Admin Force Password Reset

I currently have a functional website with user password reset in case they forget their password.  In addition to that I want to be able to click a button on my admin panel and force a password reset for a site user and generate an email with the random generated password for them to login.

How would I go about that?
Avatar of guru_sami
guru_sami
Flag of United States of America image

Does you site required user to have secret question/answer?
You can programatically, reset the password to something new using the technique shown in this article and then email the password. Here's the snippet:

string username = "user";
string password = "pass@word"; //you can generate this randomly
MembershipUser mu = Membership.Providers["SqlMembershipProviderOther"].GetUser(username);
mu.ChangePassword(mu.ResetPassword(), password);
//send email with the password above

Open in new window

Avatar of Shade22

ASKER

Yes. It runs off the .NET Membership in Visual Studios, so it requires the secret question and answer.  I was trying to figure how I would send that secret question data, or bypass the questions and generate a new password and automatically send it to the registered email address.
The article in my previous comment shows how you can bypass the q&a and reset the password.
Avatar of Shade22

ASKER

The article was almost there, but I am looking to reset the users password as an Admin and have it generate an email to the user so that they can log in with their generated temporary password and change it.
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shade22

ASKER

.