Asp.Net会员密码无符号重置
问题描述:
我在应用程序中使用asp.net成员资格提供程序。 我还使用“开箱即用”的asp:PasswordRecovery控件。Asp.Net会员密码无符号重置
我的客户抱怨发出的新密码太复杂了。 例如}> ;-(hYrS^OTfY
有什么小调整,我可以做这样的新密码只能包含字母和数字
感谢
答
这工作?!
using System;
using System.Collections.Generic;
using System.Web.Profile;
using System.Web.Security;
using System.Text;
namespace TS.Common.MembershipProvider
{
public class MembershipProvider : SqlMembershipProvider
{
/// Create an array of characters to user for password reset.
/// Exclude confusing or ambiguous characters such as 1 0 l o i
string[] characters = new string[] { "2", "3", "4", "5", "6", "7", "8",
"9", "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
const int DefaultResetPasswordLength = 10;
private int ResetPasswordLength;
// Create a more user friendly password to avoid confusion when
// trying to key in the new value
public override string GeneratePassword()
{
string newPassword = string.Empty;
System.Random rnd = new Random();
for (int i = 0; i < ResetPasswordLength; i++)
{
newPassword +=
characters[rnd.Next(characters.GetUpperBound(0))];
}
return newPassword;
}
}
}
我看了一下,但是找不到一种方法来通过web.config影响ResetPassword()的功能。您可能需要创建自己的问题解决方案。 – Greg 2009-10-06 18:35:34
本文包含有关如何创建自定义解决方案的更多信息:http://dotnet.sys-con.com/node/837990 – Greg 2009-10-06 19:28:42
感谢Greg! 我会在本周晚些时候发布自该文章开发的代码 – aron 2009-11-09 21:31:08