Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LdapActiveDirectorySearcher" /> class.
 /// </summary>
 /// <param name="ldapPath">The LDAP path.</param>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <param name="cache">The cache.</param>
 public LdapActiveDirectorySearcher(string ldapPath, string username, string password, IActiveDirectoryCache cache = null)
 {
     _adUser     = username;
     _adPassword = password;
     _ldapPath   = ldapPath;
     _cache      = cache;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LogonIdentityGroupMembershipChecker" /> class.
        /// </summary>
        /// <param name="defaultDomain">The default domain.</param>
        /// <param name="cache">The result cache.</param>
        public LogonIdentityGroupMembershipChecker(string defaultDomain = null, IActiveDirectoryCache cache = null)
        {
            if (HttpContext.Current == null)
            {
                throw new InvalidOperationException("LogonIdentityGroupMembershipChecker requires a valid HTTP context");
            }

            _cache        = cache;
            _userIdentity = HttpContext.Current.Request.LogonUserIdentity;

            // default domain prefix to remove if present, normalised to uppercase
            if (!String.IsNullOrEmpty(defaultDomain))
            {
                _defaultDomain = defaultDomain.ToUpperInvariant() + "\\";
            }
        }