我已经使用微软的“本地”组织帐户认证机制创建了一个ASP.Net MVC 5网站。这最终配置为指向我公司的ADFS基础架构。我找回所有配置的声明。但是,在运行时,ClaimsIdentity.Name是空的。这是因为ClaimsIdentity.NameClaimType,默认情况下,似乎是:如何在ASP.Net MVC 5网站中设置NameClaimType?
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
不过,我想ClaimsIdentity.Name我映射到:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier
据Microsoft Docs,地方设置这在web.config中是securityTokenHandlers元素的添加元素中:
<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<add>
<samlSecurityTokenRequirement>
<nameClaimType value=xs:string>
</nameClaimType>
</samlSecurityTokenRequirement>
</add>
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
在我的ASP.Net MVC 5 web.config中,看起来适用的唯一的事情,并通过intellisense检查结果看起来像这样:
<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<samlSecurityTokenRequirement>
<nameClaimType value="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"/>
</samlSecurityTokenRequirement>
</add>
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
但是,这似乎没有效果。我的MVC应用程序仍然报告一个空白ClaimsIdentity.Name场和ClaimsIdentity.NameClaimType仍然是:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
我应该我的web.config看起来喜欢我的现有要求到ClaimsIdentity.Name字段映射?