ASP.NET RequiresQuestionAndAnswer false 破坏 GetPassword
有点奇怪的场景。我将 RequiresQuestionAndAnswer 设置为 false,因为管理员需要能够在不填写问题和答案的情况下创建帐户,他希望用户设置该部分。
因此 RequiresQuestionAndAnswer 为 false,用户登录并提示设置自己的安全密码和答案(我自己编码,但使用一些成员身份方法来存储信息),该密码已成功存储在 aspnet_membership 表中的数据库中就像最初使用密码问题和答案创建用户一样。
然后,在 ForgotYourPassword 页面上尝试使用 Membership.Provider.GetPassword(username,passwordanswer) 时,即使密码答案错误,它也会生成密码。
这似乎是 aspnet 中的一个错误,因为将 RequiresQuestionAndAnswer 设置为 false 对我来说意味着:
“我不需要它来创建用户,但我仍然可以使用它”。
而对于 asp.net 来说则意味着:
“我不需要这个来创建用户,而且我永远不会使用它,所以它在任何地方都会被忽略。”
有人知道如何解决这个问题吗?我需要能够确认提供的安全答案是否正确并重置或获取用户的密码。我使用的是未散列的加密密码,因此应该可以检索。
slightly odd scenario. I have RequiresQuestionAndAnswer set to false because the admin needs to be able to create accounts without filling out questions and answers, he wants the user to set that part up.
So RequiresQuestionAndAnswer is false, user logs in and is prompted to set up their own security password and answer (which I've coded myself but which uses some membership methods to store the info) which is successfully stored in the DB in the aspnet_membership table just as if the user was being created with a password question and answer initially.
Then when, on the ForgotYourPassword page, when trying to use Membership.Provider.GetPassword(username,passwordanswer) it produces a password even though the password answer is wrong.
This would seem to be a fault in aspnet because setting RequiresQuestionAndAnswer to false means to me:
"I don't require this to create a user but I can still use it".
Whereas to asp.net is means:
"I don't require this to create a user and I will NEVER use it and so it will be ignored everywhere."
Anyone know how to get around this? I need to be able to confirm the provided security answer is correct and reset or get the user's password. I'm using encrypted passwords not hashed so retrieval should be possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您可能在这里发现的,内置提供程序的灵活性有些有限。解决此问题的最佳方法是让您的应用程序在幕后生成问题和答案,这样您就可以克服这个问题。
As you might be discovering here, the built-in provider is somewhat limited in it's flexibility. Best way to solve this problem is to make your app generate the question and answer behind the scenes so you can get past that.