How to get more than 100 Azure AD users from specific Azure AD Security group using @pnp/graph?

The Deep Ponkiya 1 Reputation point
2022-05-27T19:26:54.327+00:00

I have to fetch users from Azure AD particular group using @pnp/graph. But I got only 100 users from the group.

Below is my query to get a specific Azure AD group user,

const members = await graph.groups.getById("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX").members();
return members;

Can you have any idea how to get more than 100 users from the group using @pnp/graph?

Below is the reference link for the same,
https://pnp.github.io/pnpjs/graph/groups/#group-membership

Thanks

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2022-05-30T02:02:02.147+00:00

    Hi @The Deep Ponkiya ,
    Per my research, the graph has a limit of 100 schema extension property values allowed per resource instance. Here is the document you can check.
    https://learn.microsoft.com/en-us/graph/known-issues#limit-of-100-schema-extension-property-values-allowed-per-resource-instance

    If the results over 100, the response should contain a "@odata.nextLink" field which can be used to retrieve the next page of the result. An example response could be:

    {  
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",  
        "@odata.nextLink": "https://graph.microsoft.com/v1.0/users/******@domain.com/memberOf?$top=5&$skiptoken=X%2744537074090001000000000000000014000000B2B64E48AF94EB439F56F5A33CB75C9301000000000000000000000000000017312E322E3834302E3131333535362E312E342E32333331020000000000011C7FEE5EFEFA46459248691C529273D3%27",  
        "value": [  
        { ... }  
        ...  
        ]  
    }  
    

    You can retrieve the next page of results by sending the URL value of the @odata.nextLink property to Microsoft Graph.

    I will recommend you to paging Microsoft Graph data in your app. Please refer to the following document
    https://learn.microsoft.com/en-us/graph/paging


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.