Created
December 12, 2016 19:58
-
-
Save jonocairns/68b39deb4914a34391da3ea8b9361925 to your computer and use it in GitHub Desktop.
get claim identity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IPrincipal currentUser = HttpContext.Current.User; | |
var identity = User.Identity as ClaimsIdentity; | |
string claims = string.Empty; | |
if (identity != null) | |
foreach (Claim identityClaim in identity.Claims) | |
{ | |
claims += $"{identityClaim.Subject.Name}:{identityClaim.Type}:{identityClaim.Value},"; | |
} | |
string identityName = currentUser.Identity.Name; | |
return $"Hello {identityName}! claim: {claims}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment