user transitive membership filter only directory roles

Naama Almog 0 Reputation points Microsoft Employee

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:{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.
2,077 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:


    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