安全组与通讯组

时间:2016-05-26 16:27:44

标签: c# asp.net

我找到了以下代码,列出了此处的所有AD组 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
     }
 }

我想知道无论如何我们都能找到列出的群组是安全群组还是分发群组?

1 个答案:

答案 0 :(得分:0)

是。确实存在检查群组类型的方法。

请访问Find out if a group in AD is in Distribution group?

相关问题