Example #1
0
        public IEnumerable <SearchResult> GetMembers(params string[] propertiesToLoad)
        {
            var rootDse    = _Connection.GetGCDirectoryEntry(string.Empty);
            var searchRoot = rootDse.Children.Cast <DirectoryEntry>().First();

            using (var searcher = new DirectorySearcher(searchRoot, string.Format("(showInAddressBook={0})", _Path)))
            {
                if (propertiesToLoad != null)
                {
                    searcher.PropertiesToLoad.AddRange(propertiesToLoad);
                }
                searcher.SearchScope = SearchScope.Subtree;
                searcher.PageSize    = 512;
                do
                {
                    using (var result = searcher.FindAll())
                    {
                        foreach (SearchResult searchResult in result)
                        {
                            yield return(searchResult);
                        }
                        if (result.Count < 512)
                        {
                            break;
                        }
                    }
                } while (true);
            }
        }