Reputation:
Active Directory. How can I get all security groups in a specific folder?
Say my domain is "cfs". I am going to list all security groups in cfs\CHC_APP.
Thanks.
Upvotes: 2
Views: 2014
Reputation: 4503
You would do something like this:
DirectoryEntry searchBase = new DirectoryEntry("LDAP://OU=CHC_APP,DC=cfs");
DirectorySearcher searcher = new DirectorySearcher(searchBase);
searcher.Filter = "(&(objectCategory=group)(objectClass=group)(groupType:1.2.840.113556.1.4.803:=2147483648))";
SearchResultCollection results = searcher.FindAll();
//do something with results
Upvotes: 3