Reputation: 32838
I am coding an application and I would like to give the admin a way to reset a password. The closest I have come to this is the following:
public abstract string ResetPassword(string username, string answer);
But this requires I know the answer.
With the .NET MembershipProvider how can I simply reset a password to something else? The only way I can think to do this is to delete the user and recreate.
Upvotes: 1
Views: 148
Reputation: 14409
I wasn't able to do what you desire using only Membership... I had to use System.DirectoryServices.
Assuming you can get a Directory Entry, try this:
public void SetPassword( DirectoryEntry AdEntry, string userPassword )
{
ADEntry.Invoke( "SetPassword", new object[] { userPassword } );
ADEntry.CommitChanges();
}
If you need more help look here :
Howto: (Almost) Everything In Active Directory via C#
Upvotes: 0
Reputation: 26690
It's pretty easy to add the password recovery feature to an MVC project. I've got a blog post on my site where I detail the code that you need to add to your controller, model, and views:
http://hectorcorrea.com/Blog/Password-Recovery-in-an-ASP.NET-MVC-Project
Upvotes: 0
Reputation: 7361
Do you implement your custom MembershipProvider? if so set RequiresQuestionAndAnswer to false and you will not need to provide the answer in ResetPassword.
Upvotes: 1
Reputation: 22323
see:
http://www.asp.net/security/tutorials/recovering-and-changing-passwords-cs
Upvotes: 0