Wednesday, July 15, 2020

Claims Identity - Extract UPN from a claim (IIdentity)

A claim with the type IIdentity can contain multiple claims and quite often we may need to extract the value of a particular claim within. This is fairly simple like so:

var email = principal.FindFirst(ClaimTypes.Upn)?.Value;

Reference: https://docs.microsoft.com/en-us/azure/architecture/multitenant-identity/claims

No comments:

Regex obfuscate email

 Use this code in C# to obfuscate email using regex // Online C# Editor for free // Write, Edit and Run your C# code using C# Online Compile...