asp.net - 如何从本地 ADFS 声明中获取用户组

标签 asp.net vb.net wif adfs

我已按照本文使用本地 ADFS 联合构建演示应用程序。

http://www.cloudidentity.com/blog/2014/02/12/use-the-on-premises-organizational-authentication-option-adfs-with-asp-net-in-visual-studio-2013/

我可以使用简单的代码为用户获取所需的信息

Dim UserEmail = System.Security.Claims.ClaimsPrincipal.Current.FindFirst(System.IdentityModel.Claims.ClaimTypes.Email).Value

但是如何获取用户名所属的用户组并检查用户帐户是否是 Active Directory 中 Windows 组的成员?

我尝试使用 System.Security.Claims.ClaimsPrincipal.Current.IsInRole 来检查用户是否在组中,但它不起作用

最佳答案

在 ADFS 声明规则中,您需要配置规则“将 LDAP 属性作为声明发送”/“ token 组 - 不合格名称”并映射到“角色”作为“传出声明类型”。

ADFS 然后以角色格式提供用户所属的所有安全组,WIF 将它们映射到 IsInRole 构造。

关于asp.net - 如何从本地 ADFS 声明中获取用户组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24610956/

相关文章:

asp.net - FederatedAuthentication.WSFederationAuthenticationModule 在运行时为 null

asp.net-mvc - Azure ACS 2 自定义域

c# - 如何在 ASP.Net 中保存和打开 SMTP 邮件

c# - 在 Web 应用程序中使用静态方法的好处

c# - mvc脚手架从数据库中删除原始数据

c# - C# (.NET) 中的范围变量是否可行

没有 Microsoft.VisualBasic.dll 的 C# 代码

asp.net - 如何在 EditItemTemplate 中自动回发?

vb.net - 将记录添加到从另一个表获取数据的字段

wif - 尝试将 WIF 4.0 自定义 STS(来自项目模板)转换为使用 .NET 4.5