是否可以使用 Microsoft Graph 查看所有组和这些组内的所有用户?我在文档中没有看到类似的内容。
调用时:
https://graph.microsoft.com/v1.0/groups/
我获得了有关我的组的信息,但没有看到有关这些组中用户的任何信息。
我也试过打电话:
https://graph.microsoft.com/v1.0/{{userID}}/memberOf
我收到以下错误:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'memberOf'.",
"innerError": {
"request-id": "13488c8e-124f-4161-ad2b-1dc03a302dc9",
"date": "2019-03-18T16:13:23"
}
}
}
不知道为什么或者它是否甚至相关。
我向服务主体授予了所有 Microsoft Graph 权限。
最佳答案
我看到了两种可能的方法,您可以使用 -
$expand
调用组中的接线员。 GET https://graph.microsoft.com/v1.0/groups?$expand=members
通过这种方式,您可以在一次通话中获取有关组及其成员的信息。这是 Microsoft documentation on $expand parameter 的链接
免责声明:Microsoft Docs for expand 参数有一个注释,上面写着类似
With Azure AD resources that derive from directoryObject, like user and group, $expand is only supported for beta and typically returns a maximum of 20 items for the expanded relationship.
虽然,上面提到的使用 v1.0 的查询对我来说效果很好,至少从 Graph 资源管理器中使用的组成员数量很少。所以你可能需要进一步测试。
在这种方法中,您可以使用 List Members API
GET https://graph.microsoft.com/v1.0/groups/{id}/members
每个 API 所需的权限在 Microsoft Docs 链接上的相应文档中都有很好的描述。
关于azure-active-directory - 从所有组中检索所有用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55246031/