Using SharePoint REST API, how to check if a particular user is a member of a Security Group in Azure AD?

Vivek Gupta 126 Reputation points
2020-08-21T05:59:26.443+00:00

Hi,

Using SharePoint REST API, how to check if a particular user is a member of a Security Group in Azure AD?

Please provide a code example for this issue.

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,682 questions
0 comments No comments
{count} votes

Accepted answer
  1. Baker Kong-MSFT 3,791 Reputation points
    2020-08-26T06:26:00.147+00:00

    Hi @Vivek Gupta ,

    i understand you want to call MS graph api in the spfx web part. We can get it by means of pnpjs graph, it offers below method:

    Please take a reference my test demo:

    Test Result:

    20394-image.png

    20329-image.png

    *Note that not forget to grant permission for ms graph:

    Best Regards,
    Baker Kong


    If the response is helpful, please click "Accept Answer" and upvote it.


2 additional answers

Sort by: Most helpful
  1. Baker Kong-MSFT 3,791 Reputation points
    2020-08-21T07:34:20.59+00:00

    Hi VivekGupta-9563,

    I do not think SharePoint Rest API could access group resources in Azure AD, it should be specific for SP resource. Additionally MS Graph offers some endpoints that could check users membership:

    Best Regards,
    Baker Kong


    If the response is helpful, please click "Accept Answer" and upvote it.


  2. Erkan Celme 0 Reputation points
    2023-03-30T17:32:18.08+00:00

    You can use the /_api/SP.Publishing.SitePageService.GetCurrentUserMemberships endpoint to get the AD security groups, too.

    0 comments No comments