我有一个ASP.NET页面,允许管理员更改用户的密码。由于管理员不知道用户的密码,因此我使用以下命令:
MembershipUser member = Membership.GetUser(_usernameTextBox.Text); member.ChangePassword(member.ResetPassword(),_passNewTextBox.Text);
– 如SO question所述。
如果新密码不符合在web.config文件中配置的复杂性要求,则密码将被重置,但不会更改为所需的密码。如果新密码不符合复杂性要求,那么密码根本不应该改变。
有没有一种简单的方法来测试新密码的复杂性要求?
解决方法
您可以使用以下属性来测试密码:
> Membership.PasswordStrengthRegularExpression
> Membership.MinRequiredPasswordLength
> Membership.MinRequiredNonAlphanumericCharacters
请注意,如果您没有在web.config文件中配置密码,PasswordStrengthRegularExpression属性将为空字符串。
有关正则表达式匹配的信息,请参阅Regex.IsMatch(String)上的MSDN参考
感谢马特有帮助的意见。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。