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:
- Full Control
- Contribute
- Read
Each Permission Level can map to different permissions like:
- Manage Web
- Add List Items
- 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
🙂 Helpful thanks !
This was very helpful in project i’m currently working on. Cheers!