检索所有组中的所有用户? [英] Retrieve all Users from all Groups?
问题描述
是否可以使用Microsoft Graph查看所有组和这些组内的所有用户?我在文档中没有看到类似的内容.
Is it possible to see all of the Groups and all of the Users inside those Groups using Microsoft Graph? I don't see anything like that in the documentation.
呼叫时:
https://graph.microsoft.com/v1.0/groups/
我获得了有关我的网上论坛的信息,但没有看到有关这些网上论坛中用户的任何信息.
I get the information about my Groups but I don't see any information about the Users in those Groups.
我也曾尝试致电:
https://graph.microsoft.com/v1.0/{{userID}}/memberOf
,我收到以下错误消息:
and I get the following error:
{
"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"
}
}
}
不确定为什么或是否相关.
Not sure why or if it's even related.
我向服务主体授予了所有Microsoft Graph权限.
I granted the Service Principal all of the Microsoft Graph permissions.
推荐答案
我看到了两种可以使用的可能方法-
I see 2 possible approaches that you could work with -
-
在群组通话中使用
$expand
运算符.
Make use of
$expand
operator in the call for groups.
GET https://graph.microsoft.com/v1.0/groups?$expand=members
这样,您可以在一次呼叫中获取有关组及其成员的信息.这是有关$ expand参数的Microsoft文档的链接
This way you could get information about groups and it's members in a single call. Here's a link to Microsoft documentation on $expand parameter
免责声明:用于扩展参数的Microsoft文档有一个注释,内容类似于
Disclaimer: Microsoft Docs for expand parameter have a note which says something like
具有从directoryObject派生的Azure AD资源,例如用户 和组,$ expand仅受beta支持,并且通常返回 扩展关系最多20个.
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 Explorer来说确实有效.因此,您可能需要进一步测试.
Although, above mentioned query, which uses v1.0 did work fine for me at least from Graph explorer with a low number of group members. So you may need to test further.
分别查找每个组的成员
In this approach you can use List Members API
GET https://graph.microsoft.com/v1.0/groups/{id}/members
每种API所需的权限在Microsoft Docs链接的相应文档中都有很好的描述.
Permissions required for each API are pretty well described in their respective documentation on Microsoft Docs links.
这篇关于检索所有组中的所有用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!