0

I found the following piece of code which lists all the AD groups from here How to query Active Directory for all groups and group members?

 // create your domain context
 PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

 // define a "query-by-example" principal - here, we search for a  GroupPrincipal 
 GroupPrincipal qbeGroup = new GroupPrincipal(ctx);

 // create your principal searcher passing in the QBE principal    
 PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);

 // find all matches
 foreach(var found in srch.FindAll())
 {
     GroupPrincipal foundGroup = found as GroupPrincipal;

     if(foundGroup != null)
     {
        // do whatever you need to do, e.g. put name into a list of strings or something
     }
 }

I would like to know if there is anyway we can find if the groups listed are security or distribution groups?

Community
  • 1
  • 1
blue piranha
  • 3,706
  • 13
  • 57
  • 98

1 Answers1

0

Yes. There do exist the way to check out the type of group.

Please visit Find out if a group in AD is in Distribution group?

Community
  • 1
  • 1
Vikram Singh Saini
  • 1,749
  • 3
  • 22
  • 42