Created
July 20, 2012 22:05
-
-
Save sandrinodimattia/3153584 to your computer and use it in GitHub Desktop.
Get claims from principal
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
private ClaimCollection GetClaims() | |
{ | |
var claimsPrincipal = Thread.CurrentPrincipal as IClaimsPrincipal; | |
var claimsIdentity = (IClaimsIdentity)claimsPrincipal.Identity; | |
return claimsIdentity.Claims; | |
} | |
private string GetClaimValue(ClaimCollection claims, string claim) | |
{ | |
var claimRecord = claims.FirstOrDefault(o => o.ClaimType == claim); | |
if (claimRecord != null) | |
return claimRecord.Value; | |
else | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment