Click here to Skip to main content
15,889,858 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi to all!

Here I create code to get all users from Active Directory
I dont know whats the problem there


try
{
   string path = "LDAP://usihgdgfui";
   string filter = "(&(objectCategory=person))";
   string[] propertiesToLoad = new string[1] { "name" };

   using (DirectoryEntry root = new DirectoryEntry(path, "xx\\xxxx", "xxxx"))
   using (DirectorySearcher searcher = new DirectorySearcher(root, filter, propertiesToLoad))
   using (SearchResultCollection results = searcher.FindAll())
   {
      foreach (SearchResult result in results)
      {
         string name = (string)result.Properties["name"][0];
                        
         comboBox1.Items.Add(name);
      }
   }
}
catch
{
}
Posted
Updated 10-Aug-11 21:06pm
v2
Comments
[no name] 11-Aug-11 3:12am    
We don't know what the problem is either. Why don't you enlighten us with what is happening? What errors?
[no name] 11-Aug-11 3:38am    
Why don't we start with the empty catch block? As it is, all errors will disappear unnoticed into East Hyperspace.
Keith Barrow 11-Aug-11 5:21am    
That is why you generally shouldn't write catch-alls like you have in your code: you'll probably be getting a useful exception message which is sinking without trace in the catch.

1 solution

Not getting as many results as you expect? Getting a strangely even number of results? Like there's some sort of built-in limit?

Look at the searcher.PageSize property.

Set it to, say 25000 and see what happens.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900