Created
June 21, 2012 08:23
-
-
Save sandrinodimattia/2964566 to your computer and use it in GitHub Desktop.
GetClaimValue
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