public override OrCriteria Or(ADCriteria other)
 {
     return(new OrCriteria()
     {
         other
     });
 }
 public virtual AndCriteria And(ADCriteria other)
 {
     return(new AndCriteria()
     {
         this, other
     });
 }
 public override AndCriteria And(ADCriteria other)
 {
     return(new AndCriteria()
     {
         other
     });
 }
 public virtual OrCriteria Or(ADCriteria other)
 {
     return(new OrCriteria()
     {
         this, other
     });
 }
        public IEnumerable <Principal> Find(ADCriteria criteria = null, ADObjectType objectType = ADObjectType.User)
        {
            List <Principal> results = new List <Principal>();
            ADCriteria       query;

            //Get an 'entry' for the directory we want
            DirectoryEntry entry = new DirectoryEntry(String.Format("LDAP://{0}", _Name),
                                                      _userid,
                                                      _password);

            //Create a 'searcher'
            DirectorySearcher searcher = new DirectorySearcher(entry);

            if (criteria == null)
            {
                criteria = new NullCriteria();
            }

            if (objectType == ADObjectType.User)
            {
                query = criteria.And(new BaseCriteria("objectClass", "user"));
            }
            else if (objectType == ADObjectType.Group)
            {
                query = criteria.And(new BaseCriteria("objectClass", "group"));
            }
            else
            {
                query = criteria;
            }

            searcher.Filter = query.ToString();
            searcher.PropertiesToLoad.Clear();
            searcher.PropertiesToLoad.Add("cn");
            searcher.PageSize = 250;

            //For each search result...
            foreach (SearchResult result in searcher.FindAll())
            {
                Principal item = GetPrincipal(result);

                if (item != null)
                {
                    //Add a UserPrincipal object to the result list for this ID
                    results.Add(item);
                }
            }


            return(results);
        }
 public override OrCriteria Or(ADCriteria other)
 {
     return new OrCriteria() { other };
 }
 public virtual void Add(ADCriteria item)
 {
     contents.Add(item);
 }
 public override AndCriteria And(ADCriteria other)
 {
     return new AndCriteria() { other };
 }
 public virtual void Add(ADCriteria item)
 {
     contents.Add(item);
 }
 public virtual OrCriteria Or(ADCriteria other)
 {
     return new OrCriteria() { this, other };
 }
 public virtual AndCriteria And(ADCriteria other)
 {
     return new AndCriteria() { this, other };
 }
        public IEnumerable<Principal> Find(ADCriteria criteria=null, ADObjectType objectType = ADObjectType.User)
        {
            List<Principal> results = new List<Principal>();
            ADCriteria query;

            //Get an 'entry' for the directory we want
            DirectoryEntry entry = new DirectoryEntry(String.Format("LDAP://{0}", _Name),
                                                        _userid,
                                                        _password);

            //Create a 'searcher'
            DirectorySearcher searcher = new DirectorySearcher(entry);

            if (criteria == null)
            {
                criteria = new NullCriteria();
            }

            if (objectType== ADObjectType.User)
            {
                query=criteria.And(new BaseCriteria("objectClass","user"));
            }
            else if (objectType == ADObjectType.Group)
            {
                query=criteria.And(new BaseCriteria("objectClass","group"));
            }
            else
            {
                query=criteria;
            }

            searcher.Filter = query.ToString();
            searcher.PropertiesToLoad.Clear();
            searcher.PropertiesToLoad.Add("cn");
            searcher.PageSize = 250;

            //For each search result...
            foreach (SearchResult result in searcher.FindAll())
            {
                Principal item=GetPrincipal(result);

                if (item != null)
                {
                    //Add a UserPrincipal object to the result list for this ID
                    results.Add(item);
                }
            }

            return results;
        }