/// <summary> /// Initializes the provider. /// </summary> /// <param name="name">The friendly name of the provider.</param> /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception> /// <exception cref="T:System.InvalidOperationException">An attempt is made to call /// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider /// after the provider has already been initialized.</exception> /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception> public override void Initialize(string name, NameValueCollection config) { // Initialize values from web.config if (config == null) { throw new ArgumentNullException("config"); } if (name == null || name.Length == 0) { name = "UmbracoRoleProvider"; } if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Umbraco Role provider"); } // Initialize the abstract base class. base.Initialize(name, config); this._applicationName = config["applicationName"]; if (string.IsNullOrEmpty(this._applicationName)) { this._applicationName = SecUtility.GetDefaultAppName(); } }
/// <summary> /// Initializes the provider. /// </summary> /// <param name="name">The friendly name of the provider.</param> /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception> /// <exception cref="T:System.InvalidOperationException">An attempt is made to call /// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider /// has already been initialized.</exception> /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception> public override void Initialize(string name, NameValueCollection config) { // Intialize values from web.config if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(name)) { name = "UsersMembershipProvider"; } // Initialize base provider class base.Initialize(name, config); this._EnablePasswordRetrieval = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false); this._EnablePasswordReset = SecUtility.GetBooleanValue(config, "enablePasswordReset", false); this._RequiresQuestionAndAnswer = SecUtility.GetBooleanValue(config, "requiresQuestionAndAnswer", false); this._RequiresUniqueEmail = SecUtility.GetBooleanValue(config, "requiresUniqueEmail", false); this._MaxInvalidPasswordAttempts = SecUtility.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0); this._PasswordAttemptWindow = SecUtility.GetIntValue(config, "passwordAttemptWindow", 10, false, 0); this._MinRequiredPasswordLength = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, true, 0x80); this._MinRequiredNonAlphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80); this._PasswordStrengthRegularExpression = config["passwordStrengthRegularExpression"]; this._ApplicationName = config["applicationName"]; if (string.IsNullOrEmpty(this._ApplicationName)) { this._ApplicationName = SecUtility.GetDefaultAppName(); } // make sure password format is clear by default. string str = config["passwordFormat"]; if (str == null) { str = "Clear"; } switch (str.ToLower()) { case "clear": this._PasswordFormat = MembershipPasswordFormat.Clear; break; case "encrypted": this._PasswordFormat = MembershipPasswordFormat.Encrypted; break; case "hashed": this._PasswordFormat = MembershipPasswordFormat.Hashed; break; default: throw new ProviderException("Provider bad password format"); } if ((this.PasswordFormat == MembershipPasswordFormat.Hashed) && this.EnablePasswordRetrieval) { throw new ProviderException("Provider can not retrieve hashed password"); } }