When running through the MSDN article – Claims Walkthrouhgh: writing claims providers for SharePoint 2010 – I noticed that it did not clearly showed how the webparts where build which showed the overview of the claims for a specific request. Reza pointed me in the correct direction by sending me the link to a post from Steve Peschka (a must read blog for people who work with SharePoint and claims) – Figuring out what claims you have in SharePoint 2010.
Some things you should know when you try to build a claims viewer webpart of your own:
- First download the Windows Identity Foundation SDK
- Read the basics about Claim Based Identity from the Microsoft Patterns & Practices group – A guide to Claims-based Identity and Access control
The code is actually pretty simple – you can use a Visual Web Part (new in 2010) or a standard webpart – here’s a snippet
IClaimsPrincipal cp = Page.User as IClaimsPrincipal;
if (cp != null) {
IClaimsIdentity ci = (IClaimsIdentity)cp.Identity;
foreach (Claim c in ci.Claims) {
sb.Append(c.ClaimType + " " + c.Value + "<br>");
}
}
how to display claims of other user?? like as a admin i want to see other user claims
ReplyDelete