What is the easiest way to query the Active directory to get a strings list of departments names. Example: “Finance”, “Marketing”, “IT”,etc.
My case is an active directory for an enterprise with well over 3000 users.
What is the easiest way to query the Active directory to get a strings
Share
Assuming that you just want to get a list of objects with the Department attribute returned you could use a DirectorySearcher in the System.DirectoryServices namespace.
Then your filter would be something like:
and you could then tell the searcher to just load the department attribute:
Then enumerate throught the result set:
Then add each department property to a Dictionary to get all the unique values
Alternatively, there are command-line tools which will give you this information such as dsquery or adfind.
will give you a sorted list of the department attributes for all users.