Reputation: 43
Working through the example from MS site, https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-web-dotnet/
Once a user successfully signs in I cannot seem to get a hold of the claims set on the policy (in the Azure portal).
The claim object here is always null.
var type = ClaimsPrincipal.Current.Identities.First().NameClaimType;
var claim = ClaimsPrincipal.Current.FindFirst(type);
I'm hoping I'm missing something...
Upvotes: 1
Views: 1650
Reputation: 6006
You try the below code, it works perfectly fine.
ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier")
ClaimsPrincipal.Current.Claims.First(x => x.Type == "extension_ClientId")
Upvotes: 0
Reputation: 366
The NameIdentifier doesn't exist in your claims identity.
Azure b2c doesn't provide this claim.
Upvotes: 0
Reputation: 793
Do you check ClaimsPrincipal.Current.Claims? Those values are stored in ClaimsPrincipal.Current.Claims. I want to check if you cant get values from the below code in Claims page.
@foreach (Claim claim in ClaimsPrincipal.Current.Claims)
{
<tr>
<td class="claim-type claim-data">@claim.Type</td>
<td class="claim-data">@claim.Value</td>
</tr>
}
Upvotes: 1