SPSecurityTrimmedControl: Conditionally display contents by security
November 5, 2007 1 Comment
- PermissionString: (required)
Defines the permission values required to render the contents. - PermissionContext (optional):
Enumeration Values:
- PermissionContext.CurrentFolder
- PermissionContext.CurrentItem
- PermissionContext.CurrentList
- PermissionContext.CurrentSite
- PermissionContext.RootSite - PermissionMode (optional):
Allows you to define whether All permissions are required or Any permission is required to render contents.
Enumeration Values:
- PermissionMode.All
- PermissionMode.Any
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="AddAndCustomizePages">
You can place any text or HTMl in this section. Only users having the AddAndCustomizePages permission will see this.
</SharePoint:SPSecurityTrimmedControl>
If you need to, you can even create your own Security Trimmer as shown here.
http://msdn2.microsoft.com/en-us/library/aa981236.aspx
Another method worth noting is the RightsSensitiveVisibilityHelper.UserHasRights method.
https://msdn2.microsoft.com/en-us/library/ms465624.aspx
References:
-
PermissionContext Enumeration (Microsoft.SharePoint.Utilities)
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.utilities.permissioncontext.aspx - SPBasePermissions Enumeration (Microsoft.SharePoint)
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx -
PermissionMode Enumeration (Microsoft.SharePoint.Utilities)
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.utilities.permissionmode.aspx - Permission Levels and Permissions
http://office.microsoft.com/en-us/sharepointtechnology/HA101001491033.aspx - SPSecurityTrimmedControl Class
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spsecuritytrimmedcontrol.aspx - DLC’s SharePoint Platform Team Blog
http://www.sharepointplatform.com/teamblog/Lists/Posts/Post.aspx?ID=31
Awfully well executed blog post