Tutorial :Fetch all users in active directory in a specified folder


I'm doing an application which needs to query active directory and I've been using ldap queries for that purpose.

My problem is that I really cant use ou=People,dc=pisoftware,dc=com because the People node name keeps changing because my department name have been changed a lot recently. So in order to avoid the problem of having to do code change each time the name changes then I was wondering if there is any way to query by some sort of a folder id?

For example, maybe I could do ouid=123456,dc=pisoftware,dc=com


Why can't you do an ldap query which applies a filter to return back only the objectCategory=person. You then could target that query at a search base DN, so that it can still return what you want even if the ou/People nodes get renamed/changed. There is a really good guide to which shows you how to do all this and how the queries work here: http://www.rlmueller.net/ADOSearchTips.htm


Another thing you could do would be to move the search up the directory hierarchy far enough to encompass wherever the users may be and do:

myDirectorySearcher.SearchScope = SearchScope.SubTree;

which would then do a recursive sub-tree search throughout AD.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »