哪个 ADFS 声明默认映射到 Identity.Name?

Which ADFS claim maps to Identity.Name by default?

ADFS 最近是否更改了 upn 映射到 ASP.NET 中的 User.Identity.Name 的方式?

我知道的:

来自微软:

https://msdn.microsoft.com/en-us/library/mt740689(v=vs.85).aspx

When you pass a valid security token to the AD FS Web Agent, it creates an session cookie and processes the token's claims into the session's User object. This object is derived from IPrincipal, and exposes one method, IsInRole(), with which you can query the User and determine whether that user asserts the specified role claim (using a string to specify the role).

IPrincipal also exposes one property, Identity, which returns the user's identity, represented as an IIdentity object. This object can be used by the default.aspx page to determine whether the User is authenticated (by calling IsAuthenticated(). It also allows you to determine whether the user is asserting a name claim by accessing the Name property, which returns a string representing the User's name. The snippet here illustrates the use of both of these techniques.

我在 Microsoft 文档中找不到关于此的问题:

  1. "the user is asserting a name claim" 的具体含义(如:哪个 xml 属性或特定的 ADFS 声明字符串)? (这是模棱两可的:它是 "name" 声明吗?因为它读起来更像 "name claim",其中 "name" 可以松散地定义为用户名,通常 upn 用于此,过去一直在工作)
  2. 在将基于配置的身份与 ADFS(在 web.config 中定义)一起使用时,.NET 用于设置 User.Identity.Name 的确切逻辑是什么?

AFAIK,这个 "Name" 逻辑在最新版本的框架中没有改变。 例如,如 here 所述,默认情况下,用于填充 Identity.Name 属性 的声明类型始终为: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name

因此,如果您的 SAML 令牌包含此类声明,它将用作用户的 "name"(由您决定要在此声明中放入哪个 AD 属性:userPrincipalName、displayName , 邮件, ...).

此默认属性可以在代码中或在您的 web.config 中覆盖。 This page 提到了一个“<nameClaimType />”元素,老实说我不记得它是否在此期间发生了变化。 一种 注意:你的 link 真的很老了。 "ADFS Web Agent" 是第一个版本的 ADFS 的东西,但它很快被 WIF 取代了。