AccountManagement是Principal GroupPrincipal?

时间:2016-06-03 19:34:34

标签: c# active-directory principal account-management

如何接受委托人并查看是否为团体?或者它有会员?

dispatcher

1 个答案:

答案 0 :(得分:2)

你可以"转换"使用Principal关键字的as - 如果有效,如果该对象确实是GroupPrincipal,您将获得有效值,否则null

var group = GroupPrincipal.FindByIdentity(ctx, 
                                          IdentityType.DistinguishedName, 
                                          "some long dn") as GroupPrincipal;
                                                          ****************** 

if (group != null)
{
    // now you *know* that it *IS* in fact a "GroupPrincipal"
    .....
}