Asp.Net 会员密码重置(无符号)

发布于 2024-08-03 11:53:27 字数 192 浏览 5 评论 0原文

我在应用程序中使用 asp.net Membership Provider。 我还使用“开箱即用”的 asp:PasswordRecovery 控件。

我的客户抱怨所颁发的新密码太复杂。 例如 }>;-(hYrS^OTfY

我可以做一些小调整,使新密码只包含字母和数字吗?

谢谢!

I'm using the asp.net Membership Provider in an application.
I'm also using the "out of the box" asp:PasswordRecovery control.

My client is complaining that the new passwords being issued are too complicated.
e.g. }>;-(hYrS^OTfY

Are there any small tweaks I can make so the new passwords only contain letters and numbers?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

榕城若虚 2024-08-10 11:53:27

这有效:

    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;
        }
    }

}

This worked:

    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;
        }
    }

}

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