How to Access Claims Data?
-
09-12-2019 - |
题
I've seen lots of examples on mapping claims attributes in SharePoint but I'm not sure how to access that claim data programmatically.
If I have mapped the claim "SpecialId" from a custom STS and the claim provides a list of the "special" Id's how do I access that list from code?
UPDATE: All of these answers were very helpful, thank you. I gave the answer to C.Marius primarily because he was first and also because it gave me a SharePoint specific code answer.
解决方案
Someone actually built a web part extracting all claims from authenticated session
http://allthingssharepoint.wordpress.com/2011/04/14/sharepoint-claims-web-part/
C:\Marius
其他提示
I covered this at TechEd NA 2010:
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2010/OSP306
IClaimsIdentity currentIdentity = System.Threading.Thread.CurrentPrincipal.Identity as IClaimsIdentity;
//var userName = currentIdentity.Name;
foreach (Claim claim in currentIdentity.Claims)
{
// claim
}