• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MembershipPasswordFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateMembershipUser

        /// <summary>
        /// Creates the membership user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="passwordQuestion">The password question.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
        /// <param name="passwordFormat">The password format.</param>
        /// <returns></returns>
        /// <exception cref="ParameterNullException">userName
        /// or
        /// password
        /// or
        /// passwordQuestion
        /// or
        /// passwordAnswer</exception>
        /// <exception cref="System.ArgumentNullException">userName
        /// or
        /// password
        /// or
        /// passwordQuestion
        /// or
        /// passwordAnswer</exception>
        public IMembership CreateMembershipUser(string userName, string password, string emailAddress, string passwordQuestion,
                                            string passwordAnswer, bool isApproved, MembershipPasswordFormat passwordFormat)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new ParameterNullException("userName");
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ParameterNullException("password");
            }

            if (string.IsNullOrEmpty(passwordQuestion))
            {
                throw new ParameterNullException("passwordQuestion");
            }

            if (string.IsNullOrEmpty(passwordAnswer))
            {
                throw new ParameterNullException("passwordAnswer");
            }

            IMembership membership = this.membershipFactory.Create(password, isApproved, passwordQuestion, passwordAnswer, passwordFormat);
            var newMembership = this.membershipRepository.Add(membership, userName);

            return newMembership;
        }
开发者ID:danghung1202,项目名称:invergrovechurch,代码行数:53,代码来源:MembershipService.cs


示例2: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null) throw new ArgumentException("config");
            if (String.IsNullOrEmpty(name)) name = DEFAULT_PROVIDER_NAME;
            
            base.Initialize(name, config);

            applicationName = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_APPLICATION_NAME_FIELD, System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            description = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_DESCRIPTION_FIELD, "Couch DB Membership Provider");
            enablePasswordReset = ConfigurationHelper.GetConfigBoolValueOrDefault(config, ConfigurationHelper.CONFIG_ENABLE_PASSWORD_RESET, false);
            enablePasswordRetrieval = false;
            maxInvalidPasswordAttempts = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MAX_INVALID_PASSWORD_ATTEMPTS, 5);
            minRequiredNonAlphanumericCharacters = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MIN_REQUIRED_NON_ALPHANUMERIC_CHARACTERS, 0);
            minRequiredPasswordLength = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_MIN_REQUIRED_PASSWORD_LENGTH, 8);
            passwordAttemptWindow = ConfigurationHelper.GetConfigIntValueOrDefault(config, ConfigurationHelper.CONFIG_PASSWORD_ATTEMPT_WINDOW, 10);
            passwordFormat = MembershipPasswordFormat.Hashed;
            passwordStrengthRegularExpression = ConfigurationHelper.GetConfigStringValueOrDefault(config, ConfigurationHelper.CONFIG_PASSWORD_STRENGTH_REGULAR_EXPRESSION, String.Empty);
            requiresQuestionAndAnswer = ConfigurationHelper.GetConfigBoolValueOrDefault(config, ConfigurationHelper.CONFIG_REQUIRES_QUESTION_AND_ANSWER, false);
            requiresUniqueEmail = true;
            providerName = name;

            couchDbServerName = ConfigurationHelper.MembershipCouchDbServerName;
            couchDbServerPort = ConfigurationHelper.MembershipCouchDbServerPort;
            couchDbDatabaseName = ConfigurationHelper.MembershipCouchDbDatabaseName;

            if (String.IsNullOrEmpty(couchDbDatabaseName))
                throw new ProviderException(Strings.CouchDbConfigurationDatabaseNameMissing);

            machineKeySection = (MachineKeySection)WebConfigurationManager.GetWebApplicationSection("system.web/machineKey");
            if(machineKeySection == null)
                throw new ProviderException(Strings.HashedPasswordsRequireMachineKey);

            if (machineKeySection.ValidationKey.ToLower().Contains("Autogenerate".ToLower()))
                throw new ProviderException(Strings.HashedPasswordsRequireMachineKey);
        }
开发者ID:amezcua,项目名称:CouchDB.NET,代码行数:35,代码来源:CouchDbMembershipProvider.cs


示例3: PasswordSettings

 public PasswordSettings(IPasswordResetRetrievalSettings resetOrRetrieval, int minimumLength, int minimumNonAlphanumericCharacters, string regularExpressionToMatch, MembershipPasswordFormat storageFormat)
 {
     ResetOrRetrieval = resetOrRetrieval;
     MinimumLength = minimumLength;
     MinimumNonAlphanumericCharacters = minimumNonAlphanumericCharacters;
     RegularExpressionToMatch = regularExpressionToMatch;
     StorageFormat = storageFormat;
 }
开发者ID:dogbrain,项目名称:MVC3NHibernateNinjectNLog,代码行数:8,代码来源:PasswordSettings.cs


示例4: VerifyPasswordTest

        public void VerifyPasswordTest(string password, MembershipPasswordFormat format)
        {
            string salt;
            var encoded = password.Encode(out salt, format);

            var result = password.VerifyPassword(encoded, format, salt);

            result.Should().BeTrue();
        }
开发者ID:antonsamarsky,项目名称:e-commerce,代码行数:9,代码来源:SecurityHelperTest.cs


示例5: getValidationKey

        private string getValidationKey(MembershipPasswordFormat passwordFormat)
        {
            // Get encryption and decryption key information from the configuration.
            Configuration cfg = WebConfigurationManager.OpenWebConfiguration(HostingEnvironment.ApplicationVirtualPath);
            var machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
                if (passwordFormat != MembershipPasswordFormat.Clear)
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");

            return machineKey.ValidationKey;
        }
开发者ID:eneunaber,项目名称:nHibernateMembershipProvider,代码行数:13,代码来源:PasswordEncoding.cs


示例6: SqlMembershipProviderPasswordService

        /// <summary>
        /// Initializes a new <see cref="SqlMembershipProviderPasswordService"/> using the provided password format.
        /// </summary>
        /// <param name="passwordFormat">The password encryption method.</param>
        public SqlMembershipProviderPasswordService(MembershipPasswordFormat passwordFormat)
        {
            this.passwordFormat = passwordFormat;
             this.provider = new SqlMembershipProvider();

             var config = new NameValueCollection {
            { "minRequiredPasswordLength", "1" },
            { "minRequiredNonalphanumericCharacters", "0" },
            { "passwordFormat", passwordFormat.ToString() },
            { "passwordCompatMode", "Framework40" },
            { "connectionString" , "__foo__" }
             };

             this.provider.Initialize(null, config);
        }
开发者ID:rachidh,项目名称:MvcAccount,代码行数:19,代码来源:SqlMembershipProviderPasswordService.cs


示例7: EncodePassword

        public static string EncodePassword(MembershipPasswordFormat format, string cleanString, string salt)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(salt.ToLower() + cleanString);

            switch (format)
            {
                case MembershipPasswordFormat.Clear:
                    return cleanString;

                case MembershipPasswordFormat.Hashed:
                    return BitConverter.ToString(((HashAlgorithm)CryptoConfig.CreateFromName("SHA1")).ComputeHash(bytes));
            }

            return BitConverter.ToString(((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(bytes));
        }
开发者ID:davinx,项目名称:himedi,代码行数:15,代码来源:UserHelper.cs


示例8: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            // 
            // Initialize values from web.config. 
            // 

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

            _applicationName = GetConfigValue(config["applicationName"],
                                            System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            _maxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            _passwordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));
            _minRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
            _minRequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"));
            _passwordStrengthRegularExpression = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], ""));
            _enablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
            _enablePasswordRetrieval = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
            _requiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            _requiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));

            string tempFormat = config["passwordFormat"];
            if (tempFormat == null)
            {
                tempFormat = "Hashed";
            }

            switch (tempFormat)
            {
                case "Hashed":
                    _passwordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    _passwordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    _passwordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException("Password format not supported.");
            }

            // 
            // Initialize OdbcConnection. 
            //
        }
开发者ID:pbres,项目名称:24days.in.Umbraco.MembersProject,代码行数:46,代码来源:CustomMembershipProvider.cs


示例9: EncodePassword

		public static string EncodePassword(string salt, string password, MembershipPasswordFormat passwordFormat = MembershipPasswordFormat.Hashed)
		{
			switch (passwordFormat)
			{
				case MembershipPasswordFormat.Clear:
					return password;
				case MembershipPasswordFormat.Hashed:

					byte[] bytes = Encoding.Unicode.GetBytes(salt.ToLower() + password);
					byte[] inArray = null;
					HashAlgorithm algorithm = HashAlgorithm.Create(Membership.HashAlgorithmType);
					inArray = algorithm.ComputeHash(bytes);
					return Convert.ToBase64String(inArray);
				default:
					throw new NotSupportedException(String.Format("PasswordFormat is [{0}]", passwordFormat));
			}
		}
开发者ID:evkap,项目名称:DVS,代码行数:17,代码来源:PasswordHelper.cs


示例10: Decrypt

 public static String Decrypt(String encryptedValue, MembershipPasswordFormat format)
 {
     String decryptedValue = null;
     switch (format)
     {
         case MembershipPasswordFormat.Encrypted:
             CryptoManager cryptoManager = new CryptoManager();
             decryptedValue = cryptoManager.Decrypt(encryptedValue);
             break;
         case MembershipPasswordFormat.Hashed:
             throw new NotSupportedException("Hashed encrypted values cannot be decrypted");
         case MembershipPasswordFormat.Clear:
             decryptedValue = encryptedValue;
             break;
     }
     return decryptedValue;
 }
开发者ID:dufernandes,项目名称:membership-provider-nhibernate,代码行数:17,代码来源:MembershipEncryptionManager.cs


示例11: Encrypt

 public static String Encrypt(String value, MembershipPasswordFormat format)
 {
     String encryptedValue = null;
     switch (format)
     {
         case MembershipPasswordFormat.Encrypted:
             CryptoManager cryptoManager = new CryptoManager();
             encryptedValue = cryptoManager.Encrypt(value);
             break;
         case MembershipPasswordFormat.Hashed:
             encryptedValue = SHA1Manager.Encript(value);
             break;
         case MembershipPasswordFormat.Clear:
             encryptedValue = value;
             break;
     }
     return encryptedValue;
 }
开发者ID:dufernandes,项目名称:membership-provider-nhibernate,代码行数:18,代码来源:MembershipEncryptionManager.cs


示例12: UnEncodePassword

        internal string UnEncodePassword(string encodedPassword, MembershipPasswordFormat passwordFormat)
        {
            throw new ProviderException(Strings.CanNotUnencodeHashedPassword);
            //string password = encodedPassword;

            //switch (passwordFormat)
            //{
            //    case MembershipPasswordFormat.Clear:
            //        throw new ProviderException(Strings.UnsupportedPasswordFormat);
            //    case MembershipPasswordFormat.Encrypted:
            //        throw new ProviderException(Strings.UnsupportedPasswordFormat);
            //    case MembershipPasswordFormat.Hashed:
            //        throw new ProviderException(Strings.CanNotUnencodeHashedPassword);
            //    default:
            //        throw new ProviderException(Strings.UnsupportedPasswordFormat);
            //}

            //return password;
        }
开发者ID:amezcua,项目名称:CouchDB.NET,代码行数:19,代码来源:PasswordManager.cs


示例13: WinNtMembershipProvider

        public WinNtMembershipProvider()
        {
            _strName = "WinNTMembershipProvider";
            _strApplicationName = "DefaultApp";
            _userDomain = "";
            _logonType = 2; // Interactive by default

            _boolEnablePasswordReset = false;
            _boolEnablePasswordRetrieval = false;
            _boolRequiresQuestionAndAnswer = false;
            _boolRequiresUniqueEMail = false;

            _intMaxInvalidPasswordAttempts = 3;
            _intMinRequiredAlphanumericCharacters = 1;
            _intMinRequiredPasswordLength = 5;
            _strPasswordStrengthRegularExpression = @"[\w| !§$%&amp;/()=\-?\*]*";

            _oPasswordFormat = MembershipPasswordFormat.Clear;
        }
开发者ID:escherrer,项目名称:EC2Utilities,代码行数:19,代码来源:WinNtMembershipProvider.cs


示例14: CreateUser

        public CreateUserViewModel CreateUser(string salt, string pass, string encodedPasswordAnswer,
            string username, string email, string passwordQuestion, object providerUserKey,
            bool isApproved, bool requiresUniqueEmail, MembershipPasswordFormat passwordFormat)
        {
            DateTime dt = DataProviderHelper.RoundToSeconds(DateTime.UtcNow);
            var cmd = new SqlCommand("dbo.aspnet_Membership_CreateUser", Holder.Connection)
            {
                CommandTimeout = CommandTimeout,
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@ApplicationName", SqlDbType.NVarChar, ApplicationName));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@UserName", SqlDbType.NVarChar, username));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@Password", SqlDbType.NVarChar, pass));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@PasswordSalt", SqlDbType.NVarChar, salt));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@Email", SqlDbType.NVarChar, email));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@PasswordQuestion", SqlDbType.NVarChar, passwordQuestion));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@PasswordAnswer", SqlDbType.NVarChar, encodedPasswordAnswer));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@IsApproved", SqlDbType.Bit, isApproved));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@UniqueEmail", SqlDbType.Int, requiresUniqueEmail ? 1 : 0));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@PasswordFormat", SqlDbType.Int, (int)passwordFormat));
            cmd.Parameters.Add(DataProviderHelper.CreateInputParam("@CurrentTimeUtc", SqlDbType.DateTime, dt));
            SqlParameter p = DataProviderHelper.CreateInputParam("@UserId", SqlDbType.UniqueIdentifier, providerUserKey);
            p.Direction = ParameterDirection.InputOutput;
            cmd.Parameters.Add(p);

            p = new SqlParameter("@ReturnValue", SqlDbType.Int) { Direction = ParameterDirection.ReturnValue };
            cmd.Parameters.Add(p);

            cmd.ExecuteNonQuery();
            var iStatus = ((p.Value != null) ? ((int)p.Value) : -1);
            if (iStatus < 0 || iStatus > (int)MembershipCreateStatus.ProviderError)
                iStatus = (int)MembershipCreateStatus.ProviderError;
            return new CreateUserViewModel
                       {
                Status = iStatus,
                UserId = new Guid(cmd.Parameters["@UserId"].Value.ToString()),
                Date = dt
            };
        }
开发者ID:wmild,项目名称:Mild.MembershipProvider,代码行数:40,代码来源:MembershipData.cs


示例15: EncodePassword

        internal string EncodePassword(string password, MembershipPasswordFormat passwordFormat, string key)
        {
            string encodedPassword = password;

            switch (passwordFormat)
            {
                case MembershipPasswordFormat.Clear:
                    throw new ProviderException(Strings.UnsupportedPasswordFormat);
                case MembershipPasswordFormat.Encrypted:
                    throw new ProviderException(Strings.UnsupportedPasswordFormat);
                case MembershipPasswordFormat.Hashed:
                    var hash = new HMACSHA1();
                    hash.Key = HexToByte(key);
                    encodedPassword =
                      Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
                    break;
                default:
                    throw new ProviderException(Strings.UnsupportedPasswordFormat);
            }

            return encodedPassword;
        }
开发者ID:amezcua,项目名称:CouchDB.NET,代码行数:22,代码来源:PasswordManager.cs


示例16: Create

        /// <summary>
        /// Creates the specified user id.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
        /// <param name="passwordQuestion">The password question.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <param name="passwordFormat">The password format.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">password</exception>
        public IMembership Create(string password, bool isApproved,
            string passwordQuestion, string passwordAnswer, MembershipPasswordFormat passwordFormat)
        {
            if (string.IsNullOrEmpty(password))
            {
                throw new ParameterNullException("password");
            }

            if (string.IsNullOrEmpty(passwordQuestion))
            {
                throw new ParameterNullException("passwordQuestion");
            }

            if (string.IsNullOrEmpty(passwordAnswer))
            {
                throw new ParameterNullException("passwordAnswer");
            }

            var inverGrovePasswordFormat = passwordFormat.ToInverGrovePasswordFormat();

            var membership = new Membership
                             {
                                 PasswordSalt = password.GetRandomSalt(),
                                 PasswordFormatId = (int)inverGrovePasswordFormat,
                                 IsApproved = isApproved,
                                 PasswordQuestion = passwordQuestion
                             };

            var strippedSecurityAnswer = passwordAnswer.ToSecurityAnswer();
            var hashedSecurityAnswer = strippedSecurityAnswer.FormatPasscode(inverGrovePasswordFormat, membership.PasswordSalt);

            membership.Password = password.FormatPasscode(inverGrovePasswordFormat, membership.PasswordSalt);
            membership.PasswordAnswer = (inverGrovePasswordFormat == InverGrovePasswordFormat.Hashed) ? hashedSecurityAnswer : strippedSecurityAnswer;
            membership.FailedPasswordAttemptWindowStart = DateTime.MinValue.IsSqlSafeDate();
            membership.FailedPasswordAnswerAttemptWindowStart = DateTime.MinValue.IsSqlSafeDate();

            return membership;
        }
开发者ID:danghung1202,项目名称:invergrovechurch,代码行数:48,代码来源:MembershipFactory.cs


示例17: EncodePassword

        public static string EncodePassword(string pass, MembershipPasswordFormat passwordFormat, string salt)
        {
            if (passwordFormat == MembershipPasswordFormat.Clear)
                return pass;

            byte[] bIn = Encoding.Unicode.GetBytes(pass);
            byte[] bSalt = Convert.FromBase64String(salt);
            var bAll = new byte[bSalt.Length + bIn.Length];
            byte[] bRet;

            Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
            Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
            if (passwordFormat ==  MembershipPasswordFormat.Hashed)
            {
                HashAlgorithm s = HashAlgorithm.Create(Membership.HashAlgorithmType);
                bRet = s.ComputeHash(bAll);
            }
            else
            {
                bRet = EncryptPassword(bAll);
            }

            return Convert.ToBase64String(bRet);
        }
开发者ID:wmild,项目名称:Mild.MembershipProvider,代码行数:24,代码来源:DataProviderHelper.cs


示例18: CreateUserWithFormat

        private void CreateUserWithFormat(MembershipPasswordFormat format)
        {
            provider = new MySQLMembershipProvider();
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", format.ToString());
            provider.Initialize(null, config);

            // create the user
            MembershipCreateStatus status;
            provider.CreateUser("foo", "barbar!", "[email protected]", null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            // verify that the password format is hashed.
            DataTable table = FillTable("SELECT * FROM my_aspnet_Membership");
            MembershipPasswordFormat rowFormat =
                (MembershipPasswordFormat)Convert.ToInt32(table.Rows[0]["PasswordFormat"]);
            Assert.AreEqual(format, rowFormat);

            //  then attempt to verify the user
            Assert.IsTrue(provider.ValidateUser("foo", "barbar!"));
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:24,代码来源:UserManagement.cs


示例19: CheckPassword

        public bool CheckPassword(string password, string dbpassword, MembershipPasswordFormat passwordFormat)
        {
            string pass1 = password;
            string pass2 = dbpassword;

            switch (passwordFormat)
            {
                case MembershipPasswordFormat.Encrypted:
                    pass2 = _passwordEncoder.UnEncodePassword(dbpassword);
                    break;
                case MembershipPasswordFormat.Hashed:
                    pass1 = _passwordEncoder.EncodePassword(password);
                    break;
                default:
                    break;
            }

            if (pass1 == pass2)
            {
                return true;
            }

            return false;
        }
开发者ID:eneunaber,项目名称:nHibernateMembershipProvider,代码行数:24,代码来源:PasswordChecker.cs


示例20: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "CMSMembershipProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "CMS Membership provider");
            }
            base.Initialize(name, config);

            pMaxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            pPasswordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));

            var Db = GetDb();
            pMinRequiredPasswordLength = Db.Setting("PasswordMinLength", "7").ToInt();

            pMinRequiredNonAlphanumericCharacters = DbUtil.Db.Setting("PasswordRequireSpecialCharacter", "true").ToBool() ? 1 : 0;
            pPasswordStrengthRegularExpression = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], ""));
            pEnablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
            pEnablePasswordRetrieval = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
            pRequiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            pRequiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));

            string temp_format = config["passwordFormat"];
            if (temp_format == null)
                temp_format = "Hashed";

            switch (temp_format)
            {
                case "Hashed":
                    pPasswordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    pPasswordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    pPasswordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException("Password format not supported.");
            }

            // Get encryption and decryption key information from the configuration.
            Configuration cfg =
              WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");
        }
开发者ID:rossspoon,项目名称:bvcms,代码行数:57,代码来源:CMSMembershipProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MembershipUser类代码示例发布时间:2022-05-24
下一篇:
C# MembershipEntry类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap