0

I want to fetch all the users available in Active Directory. I am able to do so. I have two other options for Organizational Unit and Group Users. I want to fetch all the users of selected Item. For an example, if I choose Group Users then I am able to fetch all the groups with their users. Also for the Organizational Unit, If I select an Organization Unit then it will return all the OUs with users. I have tried a lot on web but i want found exact LDAP query. Here are some references:

OU listings , Groups Listings

Can some one could help me to get rid of this? it would be highly appreciable.

TIA...

Community
  • 1
  • 1
Ankit
  • 49
  • 2
  • 16
  • You need to narrow you search. Your search should start from selected OU as a base DN and you should add (objectClass=user) to your filter. Please post an example of your code, so I can clearly understand, what your goal is and provide you with more specific advice – oldovets Nov 10 '16 at 19:37
  • Thanks for your response. My question is How can I find all the OU Lisings with their respective Users. I dont know how many Organizational Units are available. – Ankit Nov 11 '16 at 11:22
  • You need to make a domain subtree search for all existing OUs, then for every OU in the list create a DirectoryEntry using guid binding , pass this entry to DirectorySearcher and make one level search for all users in that OU. Be aware that you cannot store all the results in memory, because the amount of data may be really huge. – oldovets Nov 11 '16 at 19:38
  • Other solution is to query a user distinguished name and search for the very right part with OU= element. However some Organizational units (eg users) have CN=Users in its name instead of OU=Users. So the best way will be to query all organizational units distinguished names, put them into a dictionary or even make a tree to decrease memory usage, then query all users distinguished names and for each user try to find the shortest path in tree or dictionary – oldovets Nov 11 '16 at 19:57

0 Answers0