public static DirectoryEntryCollection FindAllOf(this DirectorySearcher ds, AdObjectCategory category)
        {
            string str = "(objectCategory={0})";

            ds.SearchScope = SearchScope.Subtree;
            ds.PropertiesToLoad.Add(AdProperty.name.ToString());
            ds.ServerPageTimeLimit = DirectorySearcherExtensions.twoSeconds;
            ds.Filter = string.Format(str, category);
            SearchResultCollection   searchResultCollections   = ds.FindAll();
            DirectoryEntryCollection directoryEntryCollections = new DirectoryEntryCollection(searchResultCollections.Count);

            searchResultCollections.Cast <SearchResult>().ForEach <SearchResult>((SearchResult result) => directoryEntryCollections.Add(result.GetDirectoryEntry()));
            return(directoryEntryCollections);
        }
        public static DirectoryEntryCollection GetAllOf(this DirectorySearcher ds, AdObjectCategory category)
        {
            string str = "(objectCategory={0})";

            ds.SearchScope = SearchScope.OneLevel;
            StringCollection propertiesToLoad = ds.PropertiesToLoad;

            string[] strArrays = new string[] { AdProperty.name.ToString(), AdProperty.displayName.ToString() };
            propertiesToLoad.AddRange(strArrays);
            ds.ServerPageTimeLimit = DirectorySearcherExtensions.twoSeconds;
            ds.Filter = string.Format(str, category);
            SearchResultCollection   searchResultCollections   = ds.FindAll();
            DirectoryEntryCollection directoryEntryCollections = new DirectoryEntryCollection(searchResultCollections.Count);

            searchResultCollections.Cast <SearchResult>().ForEach <SearchResult>((SearchResult result) => directoryEntryCollections.Add(result.GetDirectoryEntry()));
            return(directoryEntryCollections);
        }