user transitive membership filter only directory roles

Naama Almog 0 Reputation points Microsoft Employee
2023-03-20T05:53:17.47+00:00

I'm calling 'user transitive member of' API from SDK.
Is there option to filter by groups/ directory roles in the request?

similar to running this in the in the explorer:
https://graph.microsoft-ppe.com/v1.0/users/{userId}/transitivememberof/microsoft.graph.directoryrole

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,044 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. 2023-03-20T06:17:21.2666667+00:00

    Hi @Naama Almog ,

    To List a user's memberships (direct and transitive):

    var graphClient = new GraphServiceClient(requestAdapter);
    var result = await graphClient.Users["{user-id}"].TransitiveMemberOf.GetAsync();
    

    For different SDK's there are snippets here please check them: https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http#request

     


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

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.