c# - 使用 Azure 图形 API 获取用户下的用户列表

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

我正在寻找实现如下所示的方法:

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

我可以找到引用资料,如果我提供用户 ID,它会向我提供用户报告的经理。

获取https://graph.windows.net/myorganization/users/[email protected]/$links/manager?api-version=1.6

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

但我需要相反。比如,我提供了经理 ID,并且需要该经理下的用户列表。

最佳答案

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

关于c# - 使用 Azure 图形 API 获取用户下的用户列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66323017/

相关文章:

azure - Linux 计划需要 WEBSITE_CONTENTAZUREFILECONNECTIONSTRING 和 WEBSITE_CONTENTOVERVNET 吗?

.net - .NET 中的注册表 : DeleteSubKeyTree says the subkey does not exists, 但是,嘿,确实如此!

c# - 如何确定 System.IO.IOException 的 HResult?

c# - 如何在*不*使用绑定(bind)的情况下针对对象评估 PropertyPath? (即绑定(bind)本身使用什么?)

c# - 在 C# 中的类之间共享对象

asp.net - 无效操作异常 : Could not find 'UserSecretsIdAttribute' on assembly

azure - 数据源的列表和字符串转换问题

c# - 在同一程序的多个实例之间同步

c# - 是否可以将列表添加到结构中?