【问题标题】:Claims and Roles声明和角色
【发布时间】:2015-03-27 21:41:52
【问题描述】:

我正在将 MVC5 应用程序从表单身份验证迁移到联合身份验证。我正在使用 ADFS 来联合我的应用程序,并且工作正常。我已经在 AD 中设置了组,并认为何时使用此代码:

if(ClaimsPrincipal.Current.IsInRole(@"MY-ROLE"))

如果 AD 用户实际上是“MY-ROLE”的成员,则返回 True,但情况似乎并非如此。我在这里错过了什么吗? (我是联邦服务的新手,如果我遗漏了一些明显的东西,请原谅我)

【问题讨论】:

    标签: authentication active-directory asp.net-mvc-5 adfs2.0 federated-identity


    【解决方案1】:

    您需要添加将组映射到角色的声明规则。

    将 LDAP 属性作为声明发送。

    使用“令牌组 - 非限定名称”并映射到角色

    即规则语言是:

    c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"] => issue(store = "Active Directory", types = ("http://schemas.microsoft.com/ws/2008/06/identity/claims/role"), query = ";tokenGroups;{0}", param = c.Value);

    然后,应用程序端的 WIF 将映射到 IsInRole。

    【讨论】:

      猜你喜欢
      • 2018-02-10
      • 2023-03-22
      • 2023-03-19
      • 1970-01-01
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-20
      相关资源
      最近更新 更多