Last post Jun 01, 2016 02:02 PM by dbqasp
May 31, 2016 03:14 PM|dbqasp|LINK
I found the following piece of code which lists all the AD groups from here
// 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?
Jun 01, 2016 01:10 AM|Das.Sandeep|LINK
I think below link can help you to distinguish.
Jun 01, 2016 02:02 PM|dbqasp|LINK
I had googled and found that link but couldn't understand it. Can you please explain me that scripting code? And more importantly, how can I include that script in the C# code?