Introduction
The article shows you have to hide or show the "Actions Menu" depending on the permissions of the current user; i.e., how to security trim your SharePoint pages. You do this by using theSharepoint:SPSecurityTrimmedControl
.Background
I had to give my read-only users the site-level permission "Edit Personal User Information". However, giving them this permission turned on the "Site Actions" menu displaying the "View all site content" menu item. To resolve thism I wrapped thePublishingSiteAction:SiteActionMenu
control in a Sharepoint:SPSecurityTrimmedControl
.Using the Code
SharePoint comes with a control for security trimming your pages, calledSharepoint:SPSecurityTrimmedControl
. You can use this to hide certain elements and show certain elements depending on the permissions of the current user.You use the control by:
- wrapping the control to be security trimmed with the
Sharepoint:SPSecurityTrimmedControl
. - specifying what permissions a user can have in the
Permissions
property of theSharepoint:SPSecurityTrimmedControl
.
<Sharepoint:SPSecurityTrimmedControl runat="server"
Permissions="ManagePermissions,ViewPages,BrowseUserInfo,Open,EditMyUserInfo">
<PublishingSiteAction:SiteActionMenu runat="server"/>
</SharePoint:SPSecurityTrimmedControl>
You can see the possible values that can be assigned to the Permissions
property here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx. For more info on the SPSecurityTrimmedControl
class, visit this page: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spsecuritytrimmedcontrol.aspx.