我想获得有权使用该应用程序的用户列表。
无法在本机应用程序中输入密钥。我尝试使用与登录时相同的accessToken。身份验证工作正常。 ObjectId与我的本机应用程序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的委派权限。我不确定您可以选择的最低权限(也许登录并读取用户个人资料可能有效),但是读取目录数据将为您提供必要的权限:
关于c# - 如何从Azure Active Directory(本地应用程序)获取用户列表?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50853439/