Skip to content

Instantly share code, notes, and snippets.

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