public override void Initialize(string name, NameValueCollection configSettings) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level"); if (configSettings == null) { throw new ArgumentNullException("configSettings"); } if (string.IsNullOrEmpty(name)) { name = "SqlPersonalizationProvider"; } if (string.IsNullOrEmpty(configSettings["description"])) { configSettings.Remove("description"); configSettings.Add("description", System.Web.SR.GetString("SqlPersonalizationProvider_Description")); } base.Initialize(name, configSettings); this._SchemaVersionCheck = 0; this._applicationName = configSettings["applicationName"]; if (this._applicationName != null) { configSettings.Remove("applicationName"); if (this._applicationName.Length > 0x100) { object[] args = new object[] { 0x100.ToString(CultureInfo.CurrentCulture) }; throw new ProviderException(System.Web.SR.GetString("PersonalizationProvider_ApplicationNameExceedMaxLength", args)); } } string str = configSettings["connectionStringName"]; if (string.IsNullOrEmpty(str)) { throw new ProviderException(System.Web.SR.GetString("PersonalizationProvider_NoConnection")); } configSettings.Remove("connectionStringName"); string str2 = SqlConnectionHelper.GetConnectionString(str, true, true); if (string.IsNullOrEmpty(str2)) { throw new ProviderException(System.Web.SR.GetString("PersonalizationProvider_BadConnection", new object[] { str })); } this._connectionString = str2; this._commandTimeout = SecUtility.GetIntValue(configSettings, "commandTimeout", -1, true, 0); configSettings.Remove("commandTimeout"); if (configSettings.Count > 0) { string key = configSettings.GetKey(0); throw new ProviderException(System.Web.SR.GetString("PersonalizationProvider_UnknownProp", new object[] { key, name })); } }
public override void Initialize(string name, NameValueCollection config) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level); if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = "SqlRoleProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", SR.GetString(SR.RoleSqlProvider_description)); } base.Initialize(name, config); _SchemaVersionCheck = 0; _CommandTimeout = SecUtility.GetIntValue(config, "commandTimeout", 30, true, 0); _sqlConnectionString = SecUtility.GetConnectionString(config); _AppName = config["applicationName"]; if (string.IsNullOrEmpty(_AppName)) { _AppName = SecUtility.GetDefaultAppName(); } if (_AppName.Length > 256) { throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long)); } config.Remove("connectionString"); config.Remove("connectionStringName"); config.Remove("applicationName"); config.Remove("commandTimeout"); if (config.Count > 0) { string attribUnrecognized = config.GetKey(0); if (!String.IsNullOrEmpty(attribUnrecognized)) { throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized)); } } }
public override void Initialize(string name, NameValueCollection config) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level"); if (config == null) { throw new ArgumentNullException("config"); } if ((name == null) || (name.Length < 1)) { name = "SqlProfileProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", System.Web.SR.GetString("ProfileSqlProvider_description")); } base.Initialize(name, config); this._SchemaVersionCheck = 0; this._sqlConnectionString = SecUtility.GetConnectionString(config); this._AppName = config["applicationName"]; if (string.IsNullOrEmpty(this._AppName)) { this._AppName = SecUtility.GetDefaultAppName(); } if (this._AppName.Length > 0x100) { throw new ProviderException(System.Web.SR.GetString("Provider_application_name_too_long")); } this._CommandTimeout = SecUtility.GetIntValue(config, "commandTimeout", 30, true, 0); config.Remove("commandTimeout"); config.Remove("connectionStringName"); config.Remove("connectionString"); config.Remove("applicationName"); if (config.Count > 0) { string key = config.GetKey(0); if (!string.IsNullOrEmpty(key)) { throw new ProviderException(System.Web.SR.GetString("Provider_unrecognized_attribute", new object[] { key })); } } }
/// <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 = "UmbracoMembershipProvider"; } // Initialize base provider class base.Initialize(name, config); m_providerName = name; this.m_EnablePasswordRetrieval = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false); this.m_EnablePasswordReset = SecUtility.GetBooleanValue(config, "enablePasswordReset", false); this.m_RequiresQuestionAndAnswer = SecUtility.GetBooleanValue(config, "requiresQuestionAndAnswer", false); this.m_RequiresUniqueEmail = SecUtility.GetBooleanValue(config, "requiresUniqueEmail", true); this.m_MaxInvalidPasswordAttempts = SecUtility.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0); this.m_PasswordAttemptWindow = SecUtility.GetIntValue(config, "passwordAttemptWindow", 10, false, 0); this.m_MinRequiredPasswordLength = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, true, 0x80); this.m_MinRequiredNonAlphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80); this.m_PasswordStrengthRegularExpression = config["passwordStrengthRegularExpression"]; this.m_ApplicationName = config["applicationName"]; if (string.IsNullOrEmpty(this.m_ApplicationName)) { this.m_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.m_PasswordFormat = MembershipPasswordFormat.Clear; break; case "encrypted": this.m_PasswordFormat = MembershipPasswordFormat.Encrypted; break; case "hashed": this.m_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"); } // test for membertype (if not specified, choose the first member type available) if (config["defaultMemberTypeAlias"] != null) { m_DefaultMemberTypeAlias = config["defaultMemberTypeAlias"]; } else if (MemberType.GetAll.Length == 1) { m_DefaultMemberTypeAlias = MemberType.GetAll[0].Alias; } else { throw new ProviderException("No default MemberType alias is specified in the web.config string. Please add a 'defaultMemberTypeAlias' to the add element in the provider declaration in web.config"); } // test for approve status if (config["umbracoApprovePropertyTypeAlias"] != null) { m_ApprovedPropertyTypeAlias = config["umbracoApprovePropertyTypeAlias"]; } // test for lock attempts if (config["umbracoLockPropertyTypeAlias"] != null) { m_LockPropertyTypeAlias = config["umbracoLockPropertyTypeAlias"]; } if (config["umbracoFailedPasswordAttemptsPropertyTypeAlias"] != null) { m_FailedPasswordAttemptsPropertyTypeAlias = config["umbracoFailedPasswordAttemptsPropertyTypeAlias"]; } // comment property if (config["umbracoCommentPropertyTypeAlias"] != null) { m_CommentPropertyTypeAlias = config["umbracoCommentPropertyTypeAlias"]; } // last login date if (config["umbracoLastLoginPropertyTypeAlias"] != null) { m_LastLoginPropertyTypeAlias = config["umbracoLastLoginPropertyTypeAlias"]; } // password retrieval if (config["umbracoPasswordRetrievalQuestionPropertyTypeAlias"] != null) { m_PasswordRetrievalQuestionPropertyTypeAlias = config["umbracoPasswordRetrievalQuestionPropertyTypeAlias"]; } if (config["umbracoPasswordRetrievalAnswerPropertyTypeAlias"] != null) { m_PasswordRetrievalAnswerPropertyTypeAlias = config["umbracoPasswordRetrievalAnswerPropertyTypeAlias"]; } }
public override void Initialize(string name, NameValueCollection configSettings) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level); // configSettings cannot be null because there are required settings needed below if (configSettings == null) { throw new ArgumentNullException("configSettings"); } if (String.IsNullOrEmpty(name)) { name = "SqlPersonalizationProvider"; } // description will be set from the base class' Initialize method if (string.IsNullOrEmpty(configSettings["description"])) { configSettings.Remove("description"); configSettings.Add("description", SR.GetString(SR.SqlPersonalizationProvider_Description)); } base.Initialize(name, configSettings); _SchemaVersionCheck = 0; // If not available, the default value is set in the get accessor of ApplicationName _applicationName = configSettings["applicationName"]; if (_applicationName != null) { configSettings.Remove("applicationName"); if (_applicationName.Length > maxStringLength) { throw new ProviderException(SR.GetString(SR.PersonalizationProvider_ApplicationNameExceedMaxLength, maxStringLength.ToString(CultureInfo.CurrentCulture))); } } string connectionStringName = configSettings["connectionStringName"]; if (String.IsNullOrEmpty(connectionStringName)) { throw new ProviderException(SR.GetString(SR.PersonalizationProvider_NoConnection)); } configSettings.Remove("connectionStringName"); string connectionString = SqlConnectionHelper.GetConnectionString(connectionStringName, true, true); if (String.IsNullOrEmpty(connectionString)) { throw new ProviderException(SR.GetString(SR.PersonalizationProvider_BadConnection, connectionStringName)); } _connectionString = connectionString; _commandTimeout = SecUtility.GetIntValue(configSettings, "commandTimeout", -1, true, 0); configSettings.Remove("commandTimeout"); if (configSettings.Count > 0) { string invalidAttributeName = configSettings.GetKey(0); throw new ProviderException(SR.GetString(SR.PersonalizationProvider_UnknownProp, invalidAttributeName, name)); } }
public override void Initialize(string name, NameValueCollection config) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level"); if (string.IsNullOrEmpty(name)) { name = "AuthorizationStoreRoleProvider"; } if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", System.Web.SR.GetString("RoleAuthStoreProvider_description")); } base.Initialize(name, config); this._CacheRefreshInterval = SecUtility.GetIntValue(config, "cacheRefreshInterval", 60, false, 0); this._ScopeName = config["scopeName"]; if ((this._ScopeName != null) && (this._ScopeName.Length == 0)) { this._ScopeName = null; } this._ConnectionString = config["connectionStringName"]; if ((this._ConnectionString == null) || (this._ConnectionString.Length < 1)) { throw new ProviderException(System.Web.SR.GetString("Connection_name_not_specified")); } ConnectionStringSettings settings = RuntimeConfig.GetAppConfig().ConnectionStrings.ConnectionStrings[this._ConnectionString]; if (settings == null) { throw new ProviderException(System.Web.SR.GetString("Connection_string_not_found", new object[] { this._ConnectionString })); } if (string.IsNullOrEmpty(settings.ConnectionString)) { throw new ProviderException(System.Web.SR.GetString("Connection_string_not_found", new object[] { this._ConnectionString })); } this._ConnectionString = settings.ConnectionString; this._AppName = config["applicationName"]; if (string.IsNullOrEmpty(this._AppName)) { this._AppName = SecUtility.GetDefaultAppName(); } if (this._AppName.Length > 0x100) { throw new ProviderException(System.Web.SR.GetString("Provider_application_name_too_long")); } config.Remove("connectionStringName"); config.Remove("cacheRefreshInterval"); config.Remove("applicationName"); config.Remove("scopeName"); if (config.Count > 0) { string key = config.GetKey(0); if (!string.IsNullOrEmpty(key)) { throw new ProviderException(System.Web.SR.GetString("Provider_unrecognized_attribute", new object[] { key })); } } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(name)) { name = "FRACMembershipProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "FRAC Membership Provider"); } //Initialize the base class base.Initialize(name, config); // Initialize default values _ApplicationName = "DefaultApp"; _ConnectionString = @"Data Source=ROBERTO;Initial Catalog=Kong;Integrated Security=True"; _Description = "DefaultApp"; _MinRequiredPasswordLength = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, false, 128); _MinRequiredNonalphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 128); _EnablePasswordRetrieval = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false); _EnablePasswordReset = SecUtility.GetBooleanValue(config, "enablePasswordReset", true); _Name = name; // Now go through the properties and initialize custom values foreach (string key in config.Keys) { switch (key.ToLower()) { case "applicationname": _ApplicationName = config[key]; break; case "connectionstring": _ConnectionString = config[key]; break; case "description": _Description = config[key]; break; case "requiresquestionandanswer": _RequiresQuestionAndAnswer = SecUtility.GetBooleanValue(config, key, true); break; case "requiresuniqueemail": _RequiresUniqueEmail = SecUtility.GetBooleanValue(config, key, true); break; } } string strTemp = string.IsNullOrEmpty(config["passwordFormat"]) ? "Hashed" : config["passwordFormat"]; switch (strTemp) { case "Clear": _PasswordFormat = MembershipPasswordFormat.Clear; break; case "Encrypted": _PasswordFormat = MembershipPasswordFormat.Encrypted; break; case "Hashed": _PasswordFormat = MembershipPasswordFormat.Hashed; break; default: throw new ProviderException("Bad password format"); } _HashAlgorithmType = config["hashAlgorithmType"]; if (String.IsNullOrEmpty(_HashAlgorithmType)) { _HashAlgorithmType = "SHA1"; } if (_PasswordStrengthRegularExpression != null) { _PasswordStrengthRegularExpression = _PasswordStrengthRegularExpression.Trim(); if (_PasswordStrengthRegularExpression.Length != 0) { try { Regex regex = new Regex(_PasswordStrengthRegularExpression); } catch (ArgumentException e) { throw new ProviderException(e.Message, e); } } } else { _PasswordStrengthRegularExpression = string.Empty; } if (_PasswordFormat == MembershipPasswordFormat.Hashed && _EnablePasswordRetrieval) { throw new ProviderException("Provider cannot retrieve hashed password"); } //Setup the dataops -- We probably want to change the 'connection string' to a connection string key //pointing to a web.config connection strings section _dops = new DataOps(); _dops.ConnectionString = _ConnectionString; }
public override void Initialize(string name, NameValueCollection config) { // Remove CAS from sample: HttpRuntime.CheckAspNetHostingPermission (AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level); if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = "MyMembershipProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", SR.GetString(SR.MembershipSqlProvider_description)); } base.Initialize(name, config); _EnablePasswordRetrieval = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false); _EnablePasswordReset = SecUtility.GetBooleanValue(config, "enablePasswordReset", true); _RequiresQuestionAndAnswer = SecUtility.GetBooleanValue(config, "requiresQuestionAndAnswer", true); _RequiresUniqueEmail = SecUtility.GetBooleanValue(config, "requiresUniqueEmail", true); _MaxInvalidPasswordAttempts = SecUtility.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0); _PasswordAttemptWindow = SecUtility.GetIntValue(config, "passwordAttemptWindow", 10, false, 0); _MinRequiredPasswordLength = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, false, 128); _MinRequiredNonalphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 128); _PasswordStrengthRegularExpression = config["passwordStrengthRegularExpression"]; if (_PasswordStrengthRegularExpression != null) { _PasswordStrengthRegularExpression = _PasswordStrengthRegularExpression.Trim(); if (_PasswordStrengthRegularExpression.Length != 0) { try { Regex regex = new Regex(_PasswordStrengthRegularExpression); } catch (ArgumentException e) { throw new ProviderException(e.Message, e); } } } else { _PasswordStrengthRegularExpression = string.Empty; } if (_MinRequiredNonalphanumericCharacters > _MinRequiredPasswordLength) { throw new HttpException(SR.GetString(SR.MinRequiredNonalphanumericCharacters_can_not_be_more_than_MinRequiredPasswordLength)); } config.Remove("connectionStringName"); config.Remove("enablePasswordRetrieval"); config.Remove("enablePasswordReset"); config.Remove("requiresQuestionAndAnswer"); config.Remove("applicationName"); config.Remove("requiresUniqueEmail"); config.Remove("maxInvalidPasswordAttempts"); config.Remove("passwordAttemptWindow"); config.Remove("commandTimeout"); config.Remove("passwordFormat"); config.Remove("name"); config.Remove("minRequiredPasswordLength"); config.Remove("minRequiredNonalphanumericCharacters"); config.Remove("passwordStrengthRegularExpression"); if (config.Count > 0) { string attribUnrecognized = config.GetKey(0); if (!String.IsNullOrEmpty(attribUnrecognized)) { throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized)); } } }
//////////////////////////////////////////////////////////// // Public Methods ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// public override void Initialize(string name, NameValueCollection config) { HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level); if (String.IsNullOrEmpty(name)) { name = "AuthorizationStoreRoleProvider"; } if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", SR.GetString(SR.RoleAuthStoreProvider_description)); } base.Initialize(name, config); _CacheRefreshInterval = SecUtility.GetIntValue(config, "cacheRefreshInterval", 60, false, 0); _ScopeName = config["scopeName"]; if (_ScopeName != null && _ScopeName.Length == 0) { _ScopeName = null; } _ConnectionString = config["connectionStringName"]; if (_ConnectionString == null || _ConnectionString.Length < 1) { throw new ProviderException(SR.GetString(SR.Connection_name_not_specified)); } ConnectionStringsSection sec1 = null; sec1 = RuntimeConfig.GetAppConfig().ConnectionStrings; ConnectionStringSettings connObj = sec1.ConnectionStrings[_ConnectionString]; if (connObj == null) { throw new ProviderException(SR.GetString(SR.Connection_string_not_found, _ConnectionString)); } if (string.IsNullOrEmpty(connObj.ConnectionString)) { throw new ProviderException(SR.GetString(SR.Connection_string_not_found, _ConnectionString)); } _ConnectionString = connObj.ConnectionString; _AppName = config["applicationName"]; if (string.IsNullOrEmpty(_AppName)) { _AppName = SecUtility.GetDefaultAppName(); } if (_AppName.Length > 256) { throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long)); } config.Remove("connectionStringName"); config.Remove("cacheRefreshInterval"); config.Remove("applicationName"); config.Remove("scopeName"); if (config.Count > 0) { string attribUnrecognized = config.GetKey(0); if (!String.IsNullOrEmpty(attribUnrecognized)) { throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized)); } } }