如何检查密码答案是否与 ASP.Net 中用户提供的内容匹配
我只是想知道如何手动检查用户为其安全问题的答案提供的值是否与记录中的当前答案相匹配。我想使用该构建来支持 ASP.Net 会员资格和会员用户对象。
我看到通过密码恢复控件可以返回实际答案。然而,我目前没有使用这个控件,并且需要花很多时间来集成它,因为它不满足我们用户的要求。
在最坏的情况下,获得实际答案(就像密码恢复控件所做的那样)并在我们的应用程序中手动检查它是可以接受的。
最好的情况是某种 API,我可以在其中传递用户名和所提供的安全问题的答案,并简单地获取答案是否正确的指示。
任何帮助将不胜感激。
I simply want to know how to manually check if the value a user has provided for the answer to their security question matches their current answer on record. I want to use the build in support of the ASP.Net membership and membershipuser objects.
I see that via the passwordrecovery control that the actual answer can be returned. However I am currently not using this control and it would take a good bit to integrate it as it does not meet our user's requirements.
In a worst case scenario, getting the actual answer (like the passwordrecovery control does) and manually checking it in our application would be acceptable.
A best case scenario is some sort of API where I can pass in the user name and the answer to their security question that was provided and simply get an indication of whether answer was correct or not.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先通过
Membership.GetUser
获取用户,然后调用 用户的 GetPassword 方法。如果答案错误,将会抛出MembershipPasswordException
。如果您希望立即重置密码,直接调用正确的
ResetPassword
重载可能是更好的主意。First fetch the user via
Membership.GetUser
, then call the GetPassword method on the user. AMembershipPasswordException
will be thrown if the answer is wrong.If you're looking to immediately reset the password, calling the correct
ResetPassword
overload directly might be a better idea.