哪些原因可能导致 WebSecurity.ChangePassword() 失败?
我正在开发 Razor 项目,需要将现有的用户数据库集成到 SimpleMembership Provider DB Schema 中。这是通过指定我现有的用户表以及 SimpleMembership API 将使用哪些列作为用户名和用户 ID 来完成的。
WebSecurity.InitializeDatabaseConnection("DB_ConnStr", "User", "UserId", "Username", true);
不过,在此过程中,我将使用现有数据库中每个用户行的新记录填充网页_会员表。这一切都很顺利,我已经编写了一些代码来处理每个现有用户的插入。
在插入过程中,为了简单起见,我使用虚拟加密密码令牌,并将密码设置为每个人都相同。然后,我需要对记录运行另一个脚本,为网页会员表中的每个用户设置正确的密码。这涉及从现有 User 表中解密当前密码,然后调用:
WebSecurity.ChangePassword( username, dummyPwd, newPwd)
在每个用户上,将解密的当前密码作为“newPwd”参数传递。
这在 99% 的情况下都可以正常工作 - 对于超过 100,000 条记录。但它在大约 40 个案例中失败了。
哪些原因会导致该方法失败?
I'm working on a Razor project and need to integrate an existing User database into the SimpleMembership Provider DB Schema. This is done by specifying my existing User table and which columns are to be used by the SimpleMembership API for the Username and UserID.
WebSecurity.InitializeDatabaseConnection("DB_ConnStr", "User", "UserId", "Username", true);
In the process though, I am populating the webpages_Membership table with a new record for each User row in my existing database. This has gone fine and I have written some code to handle the inserts for each existing user.
During the insert, I use a dummy encrypted password token for simplicity and set the password to be the same for everyone. Then I need to run another script over the records to set the correct password for each user in the webpages_Membership table. This involves decrypting the current password from the existing User table, and then calling:
WebSecurity.ChangePassword( username, dummyPwd, newPwd)
on each user, passing the decrypted current password as the 'newPwd' parameter.
This works fine in 99% of the cases that it's called - for over 100,000 records. But it is failing in about 40 cases.
What reasons could cause this method to fail?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的第一个猜测是新密码的哈希值可能超过 128 个字符的限制。
当 ChangePassword 调用失败时,您能否捕获异常以获取失败原因背后的详细信息?
My first guess would be that the hash of the new password might be exceeding the 128 character limit.
When the ChangePassword call fails, can you catch the exception to get details behind the reason of the failure?