1

I developed a web application. It has a login form using ASP.NET membership. Now I need to add a form allowing to change the password. Before a new password can be set, the old password must be entered by the user.

How can I check if the old password is valid?

Marek Grzenkowicz
  • 17,024
  • 9
  • 81
  • 111
Victor Athoti.
  • 829
  • 9
  • 22
  • 49

3 Answers3

1
// checking if the old password is correct
if (Membership.ValidateUser(username, oldPassword))  
{  
    // setting a new password
    string newPassword = MembershipUser.ResetPassword();  
}  

Membership.ValidateUser
Membership.ResetPassword

Marek Grzenkowicz
  • 17,024
  • 9
  • 81
  • 111
0

if The User logged In then you have the User Id

so retrieve all user Information like user name password using It.

now you Can just ask User to enter his old password now match this two if both matched then change the password with new One.

Vir
  • 1,294
  • 1
  • 13
  • 23
0

Use the ChangePassword control.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.changepassword.aspx

Greg
  • 16,540
  • 9
  • 51
  • 97