예제 #1
0
        /// <summary>
        /// Initialize provider.
        /// </summary>
        /// <param name="name">Name of provider.</param>
        /// <param name="config">Configuration setttings.</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Check to ensure configuration is specified.
            if (config == null)
            {
                throw new ArgumentNullException("No configuration specified.");
            }

            // Provide default application name if needed.
            if (string.IsNullOrWhiteSpace(name))
            {
                name = "ActiveDirectoryMembershipProvider";
            }

            // Provide description.
            if (string.IsNullOrWhiteSpace(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Active Directory Membership Provicder");
            }

            // Process configuration.
            this.Config = new ProviderConfiguration(name, config);

            // If needed to check allowedRoles, get AdConnection.
            if (this.Config.AllowedGroups.Any())
            {
                this.adConnect = new ActiveDirectory.Tools(this.Config);
            }

            // Initialize base class.
            base.Initialize(name, config);
        }
예제 #2
0
        /// <summary>
        /// Initialize AdConnection.
        /// </summary>
        /// <returns>True if connection has been initialized.</returns>
        private bool InitializeAdConnection()
        {
            // If connection already exists, return true.
            if (this.adConnect != null)
            {
                return(true);
            }

            // Get connection.
            this.adConnect = new ActiveDirectory.Tools(this.Config);

            return(this.adConnect == null);
        }