如何在Membershipuser中检查重置密码? [英] How to check reset password in Membershipuser?

查看:135
本文介绍了如何在Membershipuser中检查重置密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我要在会员用户中重置密码然后我在新密码字段中输入相同的(旧)密码,然后如果密码相同则显示消息。

Ex代码:

Hi,
I going to reset password in membership user then I have entered the same (old) password into the new password field then If password is same then display message .
Ex Code:

object objUserID = (System.Guid)Membership.GetUser(strEmployerUserName).ProviderUserKey;

MembershipUser objUsr = Membership.GetUser(objUserID); 
string strPassword = objUsr.ResetPassword(objCurrentPortalUser.UserTypeLK);

boolResult = objUsr.ChangePassword(strPassword, strNewPassword);



我使用会员控制...请帮助我...


I used membership control...Please help me...

推荐答案

首先尝试验证新密码,如果成功,这意味着它与旧密码相同,抛出异常,否则你就好了。

使用Membership.ValidateUser(UserName,newPassword);



当您使用密码格式作为哈希时,成员资格将不允许检索密码文本,因为它是单向散列(最安全),验证它比较密码的散列是否相等。
First try to validate the new password, if it is successful which means it is same as old password, throw exception otherwise you are good to go.
use Membership.ValidateUser(UserName, newPassword);

When you use passwordFormat as Hashed, membership will not allow to retrieve password text because it is one way hash (most secured), to validate it compares hash of passwords to be equal.


这篇关于如何在Membershipuser中检查重置密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆