简体   繁体   English

单个用户的Azure Active Directory组成员身份检查

[英]Azure Active Directory Group Membership check for Individual User

If one has an Azure App Service, what is the optimal, simplest way to check if a given authenticated User is a member of a given AAD Group? 如果拥有Azure应用服务,检查给定经过身份验证的用户是否是给定AAD组成员的最佳,最简单方法是什么?

The MSDN documentation for how to query AAD group membership is nightmarish, bouncing people between Microsoft Graph, Azure Active Directory Graph API, client-side endpoints and server-side code that seems to require an impossible number of IDs -- maintained between portal.azure and one's web.config. 有关如何查询AAD组成员身份的MSDN文档简直是噩梦般的,在Microsoft Graph,Azure Active Directory Graph API,客户端终结点和服务器端代码之间弹跳的人似乎需要数量不多的ID(在portal.azure之间维护)和一个人的web.config。

Has anyone found an optimal way, C# .Net side, to simply look at an AAD group and match membership? 有没有人发现C#.Net方面的最佳方法,简单地查看AAD组并匹配成员资格? (I have tried to do Claims using a Registered Azure App with Groups set to All and that path seems way too complex...) (我尝试使用已将“组”设置为“全部”的已注册Azure App进行索赔,并且该路径似乎太复杂了...)

If you have a preferred tutorial to help answer this, would be much appreciated, as MS is deprecating libraries faster than their explanation of how the old ones even worked... 如果您有首选的教程来帮助回答此问题,将不胜感激,因为MS弃用库的速度比解释旧库的工作速度更快...

The old way would be to use the Graph API and the isMemberOf function to do a transitive check if a user is in a group. 旧的方法是使用Graph APIisMemberOf 函数进行传递检查,如果用户在组中。 And, you can still do that today if you want. 而且,如果您愿意,今天仍然可以这样做。

The new way is to use the Microsoft Graph API . 新方法是使用Microsoft Graph API And as you probably know from your research, this is where the engineering teams are investing going forward. 正如您可能从研究中知道的那样,这就是工程团队正在进行投资的地方。 So, you should use the checkMemberGroups function in this API going forward. 因此,您应该在此API中继续使用checkMemberGroups 函数

There is a C# client library for the Microsoft Graph API you can use. 您可以使用Microsoft Graph API的C#客户端库。 I'm assuming you prefer this since you tagged the question with C#. 我假设您更喜欢这样做,因为您使用C#标记了问题。 As for a sample, you could look in the GitHub repository here to see how the unit tests are constructed to check a user for group membership, which essentially is a call to CheckMemberGroups , which you can see in this file . 对于示例,您可以在此处的GitHub存储库中查看如何构建单元测试以检查用户的组成员身份,这实际上是对CheckMemberGroups的调用,您可以在此文件中看到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM