一旦发布ADFS索赔,如何将用户名(HttpContext.Current.User.Identity.Name)更改为
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn 从 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
我在App_Start中的Startup.Auth.cs是
public partial class Startup
{
private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
private static string adfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieManager = new SystemWebCookieManager()
});
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = adfsMetadata
});
}
}
,startup.cs是
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
IEnumerable<Claim> claims = ClaimsPrincipal.Current.Claims;
}
}
最后,如果我访问HttpContext.Current.User.Identity.Name,我应该得到upn的值而不是Name