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

MVP, CSM, CSPO, MCP, MCTS. Sr. Software Developer. Expertise in ASP.NET MVC, Angular, AngularJs, .Net Core, C#.NET, Azure, Cognitive Services, Machine Learning, SharePoint, Azure Services, and tools, Requirement Analysis, Team Management, Pre-Sales and more. Ability to work independently and Team, handle pressure and meet commitment. Excellence Communication and adjust in any environment

Leave a Reply

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