Retrieve all Users from all Groups?

后端 未结 2 1929
天涯浪人
天涯浪人 2021-01-20 23:28

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.

When call

2条回答
  •  失恋的感觉
    2021-01-21 00:02

    I see 2 possible approaches that you could work with -

    1. Make use of $expand operator in the call for groups.

      GET https://graph.microsoft.com/v1.0/groups?$expand=members

      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

      Disclaimer: Microsoft Docs for expand parameter have a note which says something like

      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.

      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.

    2. Find members for each group individually

      In this approach you can use List Members API

       GET https://graph.microsoft.com/v1.0/groups/{id}/members
      

    Permissions required for each API are pretty well described in their respective documentation on Microsoft Docs links.

提交回复
热议问题