1
votes

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...

3

3 Answers

1
votes

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>
    }
0
votes

The NameIdentifier doesn't exist in your claims identity.

Azure b2c doesn't provide this claim.

0
votes

You try the below code, it works perfectly fine.

ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier")

or

ClaimsPrincipal.Current.Claims.First(x => x.Type == "extension_ClientId")