c# - 如何从 Azure Active Directory( native 应用程序)获取用户列表?

标签 c# azure native

我想获取有权使用该应用程序的用户列表。

无法在 native 应用程序中输入 key 。我尝试在登录时使用相同的 accessToken。身份验证工作正常。 ObjectId 与我的 native 应用程序 ObjectId 相同。

result = await authContext.AcquireTokenAsync(graphResourceId, _ADClientId, redirectUri, new PlatformParameters(PromptBehavior.Never));

string accessToken = result.AccessToken;

ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(serviceRoot, async () => await Task.FromResult(accessToken));

var groupFetcher = (IGroupFetcher)activeDirectoryClient.Groups.ExecuteAsync().Result.CurrentPage.First(g => g.ObjectId == "5deedc8c-2ba6-45d8-a4f2-xxxxxxx");

错误:Authorization_RequestDenied

出了什么问题?

最佳答案

在 Azure Active Directory 中,转到应用程序注册并添加 Windows Active Directory API 的委托(delegate)权限。我不确定您可以选择的最小权限是什么(也许登录并读取用户个人资料可能有效),但读取目录数据将为您提供必要的权限:

enter image description here

关于c# - 如何从 Azure Active Directory( native 应用程序)获取用户列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50853439/

相关文章:

c# - 将 System.Windows.Media.Pen 转换为 System.Drawing.Pen

c# - Dispatcher 只从数组中提取最后一个对象

python - 没有名为 azure.cosmos.cosmos_client 的模块

azure - 在应用程序见解中禁用另存为查询

azure - 自定义域未显示在 Azure 函数中

android - 实现简单 NDK 设置的 UnsatisfiedLinkError

node.js - 如何在 node.js 依赖树中查找 native 模块?

c# - iTextSharp `save as` 保存到用户定义的位置

c# - 收集在设计中创建的文本框

android - __android_log_print 输出 '/n' 换行 CR