我正在使用下面的代码拉取active directory组。如何判断用户是否属于xyz组?
// 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())
{
// do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
}发布于 2017-03-04 05:30:44
您可以通过查询user对象的memberOf导航属性来获取用户所属组的列表。
阅读关于它的here。
https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version请注意,您可以删除查询的$links部分以返回整个组对象,而不是对象的链接。但是,为了简单地验证用户是某个组的成员,您可以使用这些链接,并将返回的组的对象id与您正在查找的组的对象id进行比较。
https://stackoverflow.com/questions/42588322
复制相似问题