如何控制格式 MembershipUser.ResetPassword()

发布于 2024-07-11 02:09:23 字数 165 浏览 3 评论 0原文

是否可以控制通过调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

余生一个溪 2024-07-18 02:09:23

您可能需要分两步执行此操作,如 Mark Fitzpatrick 所示:http://bytes.com/groups/net-asp/689452-how-reset-users-password-without-having-use-passwordrecovery#post2740740

首先重置密码,然后立即将其更改为您喜欢的格式。 显然,不建议使用 Mark 示例中的固定字符串 - 您需要实现 一些随机字符串生成器

user.ChangePassword(user.ResetPassword(), MyMethodToGenerateRandomPassword());

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.

user.ChangePassword(user.ResetPassword(), MyMethodToGenerateRandomPassword());
叹沉浮 2024-07-18 02:09:23

现在,您还可以使用 Membership.GeneratePassword 方法并传递 MinRequiredPasswordLength 或使用 Web.config 中已定义的属性,如下所示:

  var newPassword =
                   // 0 = Number of non alphanumeric characters
                  Membership.GeneratePassword(Membership.MinRequiredPasswordLength, 0);

  user.ChangePassword(user.ResetPassword(), newPassword);

Today you can also use the Membership.GeneratePassword method and pass a MinRequiredPasswordLengthor use the property already defined in Web.config like this:

  var newPassword =
                   // 0 = Number of non alphanumeric characters
                  Membership.GeneratePassword(Membership.MinRequiredPasswordLength, 0);

  user.ChangePassword(user.ResetPassword(), newPassword);
画离情绘悲伤 2024-07-18 02:09:23

看看这篇文章 - 更改 SqlMembershipProvider 中自动生成的密码格式

我想出了一种快速方法来破解 SqlMembershipProvider 以生成不太复杂的密码,它就像创建一个继承自 SqlMembershipProvider 的新提供程序类,然后重写GeneratePassword 方法一样简单。

这不是一个完全解决的解决方案,但可能会有所帮助。

Have a look at this article - Changing the autogenerated password format in the SqlMembershipProvider.

I came up with a quick way to hack the SqlMembershipProvider to generate less complex passwords, and it was as simple as creating a new provider class that inherits from SqlMembershipProvider, then overriding the GeneratePassword method.

This is not a fully resolved solution but it might help.

素手挽清风 2024-07-18 02:09:23

我希望有一些配置设置可以使用,但重写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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文