Monday, July 23, 2012

C# code to get claims user name sharepoint 2010


IClaimsPrincipal claimsPrincipal = Page.User as IClaimsPrincipal;
if (claimsPrincipal != null)
{
IClaimsIdentity claimsIdentity = (IClaimsIdentity)Thread.CurrentPrincipal.Identity;
if (claimsIdentity != null)
{
foreach (Claim item in claimsIdentity.Claims)
{
}
}
}
Sharepoint 2010 Claims check user name 

// Comment
IClaimsPrincipal claimsPrincipal = Page.User as IClaimsPrincipal;
if (claimsPrincipal != null)
{
IClaimsIdentity claimsIdentity = (IClaimsIdentity)Thread.CurrentPrincipal.Identity;
if (claimsIdentity != null)
{
}
else
{
Logger.Instance.LogInfo("CreateChildControls", "User not found", false);
}
}

No comments:

Post a Comment