【发布时间】:2017-09-12 11:53:18
【问题描述】:
我正在使用 azure 活动目录来控制用户对我的 Web 应用程序的访问。这一切都很好,但我不知道如何识别当前登录的用户是哪个组的成员。在 ClaimsIdentity 中,我可以在 azure 中看到这两个组的设置,但我无法确定用户是其中哪个组的成员(它们仅属于 2 个组中的 1 个)。我的 web.config 中有这个代码和一个与我的管理员用户的键匹配的键,但我的两个组都在 claimidentity 对象中。那么如何确定该用户是否在我的管理员组中?
var groups = identity.Claims.Where(x => x.Type.Equals("groups")).ToList();
//this is a GUID that should match the group objectID for Adminusers in the azure active directory
string admin = Helpers.Settings.AdminUser;
if (groups.Any(c => c.Value.Contains(admin)))
{
return true;
}
else
{
return false;
}
我一定是走错路了,有人帮帮我吗?
【问题讨论】:
-
您是否考虑过按照以下页面使用 Azure Graph API msdn.microsoft.com/en-us/library/azure/ad/graph/api/…
标签: c# azure azure-active-directory