Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting ClaimTypes.Name does not result in an identity.name

I'm playing around with claimbaised authorization in .net 4.5 . This works pretty fine. But I got a hopefully small problem.

I thought that setting the name claim type should result in a identity name

I checked that ident.NameClaimType has the same value as ClaimTypes.Name Both are http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name

I set the new claim. Which i can see is part of the identity claims. but Identity.Name is still empty.

what am I doing wrong?

  ClaimsIdentity ident = (ClaimsIdentity)incomingPrincipal.Identity;

  ident.AddClaim(new Claim(ClaimTypes.Name, resourceName));
like image 989
Boas Enkler Avatar asked Sep 17 '25 09:09

Boas Enkler


1 Answers

I had the same issue when my claims identity had not AuthenticationType set. Once I have passed in an AuthenticationType in the ClaimsIdentity constructor it worked.

like image 86
user1908061 Avatar answered Sep 19 '25 00:09

user1908061