0
votes

I am looking to implement a method something like below:

If I pass a manager Id to my method, then it needs to give me the list of users whoever report to that manager.

I could find reference where, if I provide a user Id, it gives me the manager to whom the user reports.

GET https://graph.windows.net/myorganization/users/john@contoso.onmicrosoft.com/$links/manager?api-version=1.6

https://docs.microsoft.com/en-us/previous-versions/azure/ad/graph/api/users-operations

But I need vice-versa. Something like, I provide the manager Id and I need the list of users under that manager.

1
What do you mean under that user exactly? It's not a term I'm familiar with when discussing active directory. Can you relate it to a specific feature and give the technical name pleaseADyson
Sorry, I mean to say member. Need to fetch the direct members under the passed parameter user_iduser2083386
users don't have members. Do you mean you want to get all users who are members of a group?ADyson
I updated the question.user2083386
Ok thanks. That's a lot clearer now. docs.microsoft.com/en-us/graph/api/… looks like it might be what you needADyson

1 Answers

2
votes

Install the Microsoft Graph .NET SDK here.

Use Client credentials provider to generate the authProvider.

Code sample:

IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
    .Create(clientId)
    .WithTenantId(tenantID)
    .WithClientSecret(clientSecret)
    .Build();

ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

var directReports = await graphClient.Users["{upn or user_object_id}"].DirectReports
    .Request()
    .GetAsync();