当前位置: 首页>>代码示例>>C#>>正文


C# MembershipPasswordFormat.Equals方法代码示例

本文整理汇总了C#中MembershipPasswordFormat.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipPasswordFormat.Equals方法的具体用法?C# MembershipPasswordFormat.Equals怎么用?C# MembershipPasswordFormat.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MembershipPasswordFormat的用法示例。


在下文中一共展示了MembershipPasswordFormat.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        /// <summary>
        /// System.Configuration.Provider.ProviderBase.Initialize Method.
        /// </summary>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize values from web.config.
            if (config == null)
                throw new ArgumentNullException("config", Properties.Resources.ErrArgumentNull);

            if (string.IsNullOrEmpty(name))
                name = Properties.Resources.MembershipProviderDefaultName;

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", Properties.Resources.MembershipProviderDefaultDescription);
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            m_applicationName = GetConfigValue(config["applicationName"], HostingEnvironment.ApplicationVirtualPath);
            m_maxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"), CultureInfo.InvariantCulture);
            m_passwordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"), CultureInfo.InvariantCulture);
            m_minRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"), CultureInfo.InvariantCulture);
            m_minRequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"), CultureInfo.InvariantCulture);
            m_passwordStrengthRegularExpression = GetConfigValue(config["passwordStrengthRegularExpression"], "");
            m_enablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"), CultureInfo.InvariantCulture);
            m_enablePasswordRetrieval = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"), CultureInfo.InvariantCulture);
            m_requiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"), CultureInfo.InvariantCulture);
            m_requiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"), CultureInfo.InvariantCulture);

            // Get password encryption type.
            string pwFormat = GetConfigValue(config["passwordFormat"], "Hashed");
            switch (pwFormat)
            {
                case "Hashed":
                    m_passwordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    m_passwordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    m_passwordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException(Properties.Resources.ErrPwFormatNotSupported);
            }

            // Get connection string.
            m_connectionString = GetConnectionString(config["connectionStringName"]);

            // Check whether we are on a web hosted application or not
            // If we're web hosted use the Web.config; otherwise the application's config file
            Configuration cfg = HttpContext.Current != null
                                    ? WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath)
                                    : ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            // Get encryption and decryption key information from the configuration.
            m_machineKeyConfig = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (!m_passwordFormat.Equals(MembershipPasswordFormat.Clear))
            {
                if (m_machineKeyConfig == null)
                    throw new ProviderException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ErrConfigSectionNotFound, "system.web/machineKey"));

                if (m_machineKeyConfig.ValidationKey.Contains("AutoGenerate"))
                    throw new ProviderException(Properties.Resources.ErrAutoGeneratedKeyNotSupported);
            }
        }
开发者ID:JasonSznol,项目名称:AspSQLProvider,代码行数:70,代码来源:PgMembershipProvider.cs


注:本文中的MembershipPasswordFormat.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。