This post explain about Security Trimmed Control and how to use in SharePoint with out custom coding. We can do security trimmed from SharePoint Designer for different users based of their permission.

A user can be given a permission level like:

  1. Full Control
  2. Contribute
  3. Read

Each Permission Level can map to different permissions like:

  1. Manage Web
  2. Add List Items
  3. View Pages

Security Trimmed Control

The assembly Microsoft.SharePoint.WebControls contains a control named SPSecurityTrimmedControl that does the security trimming of the child controls inside it. Just include our control inside this control and it will be displayed or hidden based on the permission specified.

Sample:

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
 Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, 
PublicKeyToken=71e9bce111e9429c" %> 
<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server" 
AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="ManageWeb" 
PermissionContext="CurrentSite"> 
 <INCLUDE OUR CONTROL HERE> 
</SharePoint:SPSecurityTrimmedControl>

For Full Control Permission’s Users

Permission=”ManageWeb”

 

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server"  
AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="ManageWeb" 
PermissionContext="CurrentSite">  

    //...... your other control ....//

</SharePoint:SPSecurityTrimmedControl>

For Contribute or higher Permission’s Users

Permission=”AddListItems

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server"  
AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="AddListItems" 
PermissionContext="CurrentSite">  

    //...... your other control ....//

</SharePoint:SPSecurityTrimmedControl>

For Read or higher Permission’s Users

Permission=”ViewPages

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server"  
AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="ViewPages" 
PermissionContext="CurrentSite">  

    //...... your other control ....//

</SharePoint:SPSecurityTrimmedControl>

All these security trimmed can be added by editing Snippet Gallery both in master page or other pages.

For further more info:
Check This

 

 

By Rijwan Ansari

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ https://rijsat.com Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in c-sharpcorner.com community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

2 thoughts on “Security Trimmed Control in SharePoint 2013”

Leave a Reply

Your email address will not be published. Required fields are marked *