How to change user password in net2.0
Author:Eve Cole
Update Time:2009-06-30 15:56:19
In net2.0, the MembershipUser class has a ChangePassword method, but it has two parameters,
Old password and new password, but here comes the question, how do I know the user's old password? If I, as an administrator, want to change the user's password, the solution is as follows, first give the user ResetPassword
Code:
MembershipUser user = Membership.GetUser(txtFindUserName.Text.ToString().Trim());
user.UnlockUser();
string oldPass = user.ResetPassword();
string newPass = txtFindUserPass.Text.ToString().Trim();
if (newPass.Length < 6)
{
return;
}
user.ChangePassword(oldPass,newPass);