如何控制格式 MembershipUser.ResetPassword()
是否可以控制通过调用 MembershipUser.ResetPassword() 自动生成的密码的格式?
我希望能够允许或不允许在生成的密码中使用某些特殊字符。
我正在使用密码格式为 Hashed 的 SqlMembershipProvider。
谢谢。
Is it possible to control the format of the password that is automatically generated by a call to MembershipUser.ResetPassword()?
I want to be able to allow or not allow certain special characters in the generated password.
I am using the SqlMembershipProvider with a password format of Hashed.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能需要分两步执行此操作,如 Mark Fitzpatrick 所示:http://bytes.com/groups/net-asp/689452-how-reset-users-password-without-having-use-passwordrecovery#post2740740
首先重置密码,然后立即将其更改为您喜欢的格式。 显然,不建议使用 Mark 示例中的固定字符串 - 您需要实现 一些随机字符串生成器。
You may want to do this in two steps, as identified by Mark Fitzpatrick here: http://bytes.com/groups/net-asp/689452-how-reset-users-password-without-having-use-passwordrecovery#post2740740
First Reset the password, then immediately change it to a format of your liking. Obviously using a fixed string as in Mark's example would NOT be recommended - you'd want to implement some random string generator.
现在,您还可以使用
Membership.GeneratePassword
方法并传递MinRequiredPasswordLength
或使用 Web.config 中已定义的属性,如下所示:Today you can also use the
Membership.GeneratePassword
method and pass aMinRequiredPasswordLength
or use the property already defined in Web.config like this:看看这篇文章 - 更改 SqlMembershipProvider 中自动生成的密码格式。
这不是一个完全解决的解决方案,但可能会有所帮助。
Have a look at this article - Changing the autogenerated password format in the SqlMembershipProvider.
This is not a fully resolved solution but it might help.
我希望有一些配置设置可以使用,但重写GeneratePassword()方法适合我的情况。
我们已经有了一个加密实用程序类,可以生成随机密码字符串,因此这是一个非常快速的更改。
I was hoping that there would be some configuration setting could use but overriding the GeneratePassword() method works for my situation.
We already had a crypto utility class that would generate the random password strings so it was a pretty quick change.