开发者

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?


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

Membership.ValidateUser
Membership.ResetPassword


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.


Use the ChangePassword control.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜