【问题标题】:Get list of users under a user using Azure graph API使用 Azure 图形 API 获取用户下的用户列表
【发布时间】:2021-02-22 20:33:21
【问题描述】:

我希望实现如下方法:

如果我将经理 ID 传递给我的方法,那么它需要向我提供向该经理报告的用户列表。

我可以在哪里找到参考,如果我提供用户 ID,它会为我提供用户向其报告的经理。

获取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

但我需要反之亦然。例如,我提供了经理 ID,我需要该经理下的用户列表。

【问题讨论】:

  • under that user 到底是什么意思?在讨论活动目录时,这不是我熟悉的术语。您能否将其与特定功能联系起来并给出技术名称
  • 对不起,我是说会员。需要取传参数user_id下的直接成员
  • 用户没有成员。您的意思是要获取属于 group 的所有用户吗?
  • 我更新了问题。
  • 好的,谢谢。现在清楚多了。 docs.microsoft.com/en-us/graph/api/… 看起来可能是你需要的

标签: c# .net azure azure-functions azure-ad-graph-api


【解决方案1】:

安装 Microsoft Graph .NET SDK here

使用Client credentials provider 生成authProvider。

代码示例:

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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多