c# - 使用 Azure 图形 API 获取用户下的用户列表
问题描述
我正在寻找实现如下方法:
如果我将经理 ID 传递给我的方法,那么它需要向我提供向该经理报告的用户列表。
我可以在哪里找到参考,如果我提供用户 ID,它会为我提供用户向其报告的经理。
https://docs.microsoft.com/en-us/previous-versions/azure/ad/graph/api/users-operations
但我需要反过来。例如,我提供了经理 ID,我需要该经理下的用户列表。
解决方案
在此处安装 Microsoft Graph .NET SDK 。
使用客户端凭据提供程序生成 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();
推荐阅读
- excel - 如何自动展开下拉验证列表
- javascript - 使用表单的快速删除请求不起作用
- javascript - 做一个带时间戳的进度条
- android - 保存图片文件Uri出错保存空指针异常
- css - flexbox 导航栏切换
- python - 我的 python 脚本可以知道它是从 IDE 手动启动还是从调度程序自动启动?
- selenium - 测量 Selenium 中多个 Web 元素的加载时间
- ms-access - MS-Access - 使用加入另一个表的结果更新列
- apache - apache httpd.conf - 文件/路径名中的空格
- scala - Spark Scala,同时训练多个模型