Exemple #1
0
        /// <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>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "SnitzRoleProvider";
            }

            EnsureString(config, "description", @"Snitz Role Provider");

            base.Initialize(name, config);

            string databaseName = config["connectionStringName"];

            if (String.IsNullOrEmpty(databaseName))
            {
                throw new ProviderException("The attribute 'connectionStringName' is missing or empty.");
            }

            if (db == null)
            {
                ConnectionStringSettings csSettings = ConfigurationManager.ConnectionStrings[databaseName];
                db = new SnitzMemberDataContext(csSettings.ConnectionString);
            }

            _config = config;
        }
Exemple #2
0
        /// <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)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "SnitzMembershipProvider";
            }

            EnsureString(config, "description", @"Snitz Membership Provider");

            base.Initialize(name, config);


            string databaseName = config["connectionStringName"];

            if (String.IsNullOrEmpty(databaseName))
            {
                throw new ProviderException("The attribute 'connectionStringName' is missing or empty.");
            }
            if (_db == null)
            {
                ConnectionStringSettings csSettings = ConfigurationManager.ConnectionStrings[databaseName];
                _db = new SnitzMemberDataContext(csSettings.ConnectionString);
            }

            _config = config;

            // Set Default parameters
            EnsureInt(_config, "MaxInvalidPasswordAttempts", 3);
            EnsureInt(_config, "MinRequiredNonAlphanumericCharacters", 0);
            EnsureInt(_config, "MinRequiredPasswordLength", 5);
            EnsureInt(_config, "PasswordAttemptWindow", 20);
            EnsureBoolean(_config, "RequiresUniqueEmail", true);
            EnsureString(_config, "PasswordStrengthRegularExpression", "");
        }