user1108948
user1108948

Reputation:

Get all security groups under specific folder

Active Directory. How can I get all security groups in a specific folder?

AD

Say my domain is "cfs". I am going to list all security groups in cfs\CHC_APP.

Thanks.

Upvotes: 2

Views: 2014

Answers (1)

Brian Desmond
Brian Desmond

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

Related Questions