Victor Athoti.
Victor Athoti.

Reputation: 831

how to change the password in membership with oldpassword checking

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?

Upvotes: 1

Views: 1309

Answers (3)

Greg
Greg

Reputation: 16680

Use the ChangePassword control.

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

Upvotes: 0

Marek Grzenkowicz
Marek Grzenkowicz

Reputation: 17333

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

Membership.ValidateUser
Membership.ResetPassword

Upvotes: 1

Vir
Vir

Reputation: 1354

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.

Upvotes: 0

Related Questions