asp.net membership change password without knowing old one

Lalit picture Lalit · Feb 16, 2011 · Viewed 46.2k times · Source

Evaluting the method signature, it is required to know old password while changing it.

membershipUser.ChangePassword(userWrapper.OldPassword, userWrapper.Password)

Is there any way to change password without knowing old one.

Answer

ajma picture ajma · Feb 16, 2011
 string username = "username";
 string password = "newpassword";
 MembershipUser mu = Membership.GetUser(username);
 mu.ChangePassword(mu.ResetPassword(), password);