locked
more data is available with directorysearcher and framework 3.5 RRS feed

  • Question

  • Hi to all,

    i'm using the following code in a console application to extract a list of replication conflicts in one OU with about 3 million of users:

    try                                                                                              
    {                                                                                                
        using (DirectoryEntry de = new DirectoryEntry("LDAP://OU=outosearch, DC=domain, DC=local"))           
            using (DirectorySearcher searcher = new DirectorySearcher())                             
            {                                                                                        
                searcher.SearchRoot = de;                                                            
                searcher.SearchScope = SearchScope.Subtree;                                          
                searcher.Filter = "(|(CN=*\\0ACNF:*)(OU=*\\0ACNF:*))";                               
                searcher.CacheResults = false;                                                                                                                          
                searcher.PageSize = 100000;                                                                      
                searcher.PropertiesToLoad.AddRange(new String[] { "Name" });                         
                SearchResultCollection results = searcher.FindAll();                                 
               
                foreach (SearchResult result in results)                                             
                {                                                                                     
                    Console.WriteLine(result.GetDirectoryEntry().Properties["Name"]);              
                }                                                                                    
            }                                                                                                                                                                                          
    }                                                                                                
    catch (Exception excep)                                                                          
    {                                                                                                
        Console.WriteLine(excep.Message);                                                            
        return;                                                                                      
    }                                                                                                

    Unfortunately the application generates an exception: "More data is available.".

    I founs a know problem with framework 1.1 (http://support.microsoft.com/kb/833789) but with framework 2 and 2.5 i have the same error.

    For the moment, the only way i found, is using the System.DirectoryServices.Protocol.

    Is there a solution or workaround using System.DirectoryService and a directorysearcher collection ?

     

    Thank You

    Fabio.

    • Moved by Chao Kuo Monday, March 29, 2010 10:11 AM Active directory (From:Visual C# General)
    Tuesday, March 23, 2010 11:20 AM

Answers