Saturday, October 23, 2021

Security Trimmed Control in SharePoint 2013

 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

No comments:

Post a Comment

No String Argument Constructor/Factory Method to Deserialize From String Value

  In this short article, we will cover in-depth the   JsonMappingException: no String-argument constructor/factory method to deserialize fro...