Thursday, May 21, 2009

One Step at a time - Changing a password

If in asp.net you want to change a password but don't know the current password you need to generate a new one and use it to change the password. So to change a users password to "abc123"

MembershipUser mUser = Membership.GetUser(username);
string tmpPassword = mUser.ResetPassword();
bool PassswordChanged = mUser.ChangePassword(tmpPassword, "abc123");
because
mUser.SetPassword( "abc123");
Just didn't makes sense. Don't tell me what to do I'll write my own policies.

No comments:

Post a Comment