Exemplo n.º 1
0
        public CustomMembershipProvider()
        {
            _requiresUniqueEmail                  = true;
            _applicationName                      = "/";
            _enablePasswordReset                  = false;
            _enablePasswordRetrieval              = false;
            _maxInvalidPasswordAttempts           = 0;
            _requiresQuestionAndAnswer            = true;
            _minRequiredNonAlphanumericCharacters = 0;
            _minRequiredPasswordLength            = 6;
            _passwordAttemptWindow                = 5;
            _passwordFormat = MembershipPasswordFormat.Hashed;
            _passwordStrengthRegularExpression = "";

            ProviderSettings providerSettings = SecurityUtility.GetMembershipProviderSettings();

            _providerName = providerSettings.Name;
            foreach (string index in providerSettings.Parameters.AllKeys)
            {
                switch (index.ToLower())
                {
                case "applicationname":
                    _applicationName = providerSettings.Parameters[index];
                    break;

                case "enablepasswordreset":
                    _enablePasswordReset = ValueUtilities.GetBoolean(providerSettings.Parameters[index], false);
                    break;

                case "enablepasswordretrieval":
                    _enablePasswordRetrieval = ValueUtilities.GetBoolean(providerSettings.Parameters[index], false);
                    break;

                case "maxinvalidpasswordattempts":
                    _maxInvalidPasswordAttempts = ValueUtilities.GetInt32(providerSettings.Parameters[index], 5);
                    break;

                case "minrequirednonalphanumericcharacters":
                    _minRequiredNonAlphanumericCharacters = ValueUtilities.GetInt32(providerSettings.Parameters[index], 3);
                    break;

                case "minrequiredpasswordlength":
                    _minRequiredPasswordLength = ValueUtilities.GetInt32(providerSettings.Parameters[index], 8);
                    break;

                case "passwordattemptwindow":
                    _passwordAttemptWindow = ValueUtilities.GetInt32(providerSettings.Parameters[index], 5);
                    break;

                case "passwordformat":
                    _passwordFormat = ValueUtilities.GetEnumerationValue <MembershipPasswordFormat>(providerSettings.Parameters[index]);
                    break;

                case "passwordstrengthregularexpression":
                    _passwordStrengthRegularExpression = providerSettings.Parameters[index] ?? string.Empty;
                    break;

                case "requiresquestionandanswer":
                    _requiresQuestionAndAnswer = ValueUtilities.GetBoolean(providerSettings.Parameters[index], true);
                    break;

                case "requiresuniqueemail":
                    _requiresUniqueEmail = ValueUtilities.GetBoolean(providerSettings.Parameters[index], true);
                    break;
                }
            }
        }