Exploring Claims Viewer Web Part

About Web Part

I was working in a Claims enabled SharePoint Web Application, where I felt the need of a Claims Viewer component which can display the current claims of the logged-in user.

An example is displayed below:


Web Part

The above component is developed as a Web part and requires a Farm Solution for deployment. The C# code runs in the Server-side and renders the Claims values to the output.


Following is the code which retrieves the claims:

  1. protected void Page_Load(object sender, EventArgs e)  
  2. {  
  3.     IClaimsPrincipal principal = Thread.CurrentPrincipal as IClaimsPrincipal;  
  4.     IClaimsIdentity identity = principal.Identity as IClaimsIdentity;  
  6.     IList < ClaimEntity > list = new List < ClaimEntity > ();  
  8.     foreach(Claim claim in identity.Claims)  
  9.     list.Add(new ClaimEntity()  
  10.     {  
  11.         ClaimType = claim.ClaimType,  
  12.             Value = claim.Value,  
  13.             ValueType = claim.ValueType  
  14.     });  
  16.     RefreshGrid(list);  
  17. }  
Once the user is logged in, the thread will contain the Claims Principal object. We can get the Claims from this object.

Each Claim will have the following, 
  • Claim Type is the pre-defined URL
  • Claim Value is the actual claim value eg: Windows\administrator

Note: You can use the References for articles on Installation of the Claims Viewer Web part.

Claims Viewer Web Part - Installation


You can go to this link to get the Web part.

From there, choose the downloads page.


You will get the WSP file.


The Web part is free for development & commercial use.


Once you have downloaded the WSP file, you need to install it. This is a Farm Solution so you require PowerShell.

Go to your SharePoint Server and open the PowerShell Window in administrator mode.

Administrator mode

You will get the following command Window:


Run the following command to add the WSP package to Farm Solutions:

  • Add-SPSolution “full path”
  • Eg: Add-SPSolution “c:\shared\ ClaimsViewerWebPart2013.wsp”,

If things went well, you will get the following snapshot:


Now, run the following command to install the WSP package:

  • Install-SPSoluton ClaimsViewerWebPart2013.wsp –gacdeployment –webapplication http://yourserver
If things went well, you will get the following output with no error messages:


Now, you can come to your SharePoint site > Go to Site Collection features > Activate the following feature:


Once you have activated the feature, you can add the Web Part to a page.

Create a new page and choose the Insert Web part option. You should be able to see the Claims Web part as shown below:

web part

Insert the Web part & Save the page. You are ready to use the Claims Viewer Web part.

web part

Note: Your claims may be different from the items shown above.


Summary: In this article, we have explored how to install the Claims Viewer Web part.

Up Next
    Ebook Download
    View all
    View all