Answered by:
Sharepoint Security trimming ribbon

Question
-
Hi,
We are stripping down our ribbon to just a few basic controls for our users. I have done this using a feature and the TrimByID command. However, we would really like a way of allowing people with administrative rights to be able to view the entire ribbon. We thought that by using the Sharepoint <Sharepoint:SPSecurityTrimmedControl> control, and wrapping this around the control where it's referenced in the MasterPage, that it would do the job but we tried testing it and found that it made no difference for any level of user, the ribbon remained trimmed.
Does anyone know of a way to get this to work (which it seems, in theory, it should do)? Or anybody have any further techniques for what we're trying to do here.
Thanks in advance
Tuesday, January 18, 2011 3:06 PM
Answers
-
We have overcome this issue by placing a security IF statement in the ribbon trimming control itself.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim ribbon As SPRibbon = SPRibbon.GetCurrent(Me.Page) If ribbon IsNot Nothing And Not (SPContext.Current.Web.CurrentUser.IsSiteAdmin) Then ribbon.TrimById("Ribbon.Library") ribbon.TrimById("Ribbon.Documents.EditCheckout") ribbon.TrimById("Ribbon.Documents.Manage") ribbon.TrimById("Ribbon.Documents.Share") ribbon.TrimById("Ribbon.Documents.Copies") ribbon.TrimById("Ribbon.Documents.Workflow") ribbon.TrimById("Ribbon.Documents.QuickSteps") ribbon.TrimById("Ribbon.Documents.FormActions") ribbon.TrimById("Ribbon.Documents.New.NewFolder") ribbon.TrimById("Ribbon.WikiPageTab") ribbon.TrimById("Ribbon.PublishTab") End If End Sub
- Marked as answer by Ryan Greenaway Wednesday, January 19, 2011 2:20 PM
Wednesday, January 19, 2011 2:20 PM
All replies
-
Hi,
This is an example how hide the ribbon based on user permissions.
Hope it helps.
Regards,
Vladimir
MSTS, SharePoint tips blog: http://buyevich.blogspot.comTuesday, January 18, 2011 3:45 PM -
Hi
Can you tell us the exact procedure you followed and the code that you added.
Check this site
http://fusionovation.com/blogs/mbell/archive/2008/09/18/security-trimmed-controls-in-sharepoint.aspx
Tuesday, January 18, 2011 4:05 PM -
Hi
Can you tell us the exact procedure you followed and the code that you added.
Check this site
http://fusionovation.com/blogs/mbell/archive/2008/09/18/security-trimmed-controls-in-sharepoint.aspx
I created a control which was activated in a feature containing this codeImports System Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports Microsoft.SharePoint.WebControls Namespace CONTROLTEMPLATES.SPR.Utilities Partial Public Class RibbonItemHider Inherits UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim ribbon As SPRibbon = SPRibbon.GetCurrent(Me.Page) If ribbon IsNot Nothing Then 'ribbon.TrimById("Ribbon.Library") ribbon.TrimById("Ribbon.Documents.EditCheckout") ribbon.TrimById("Ribbon.Documents.Manage") ribbon.TrimById("Ribbon.Documents.Share") ribbon.TrimById("Ribbon.Documents.Copies") ribbon.TrimById("Ribbon.Documents.Workflow") ribbon.TrimById("Ribbon.Documents.QuickSteps") ribbon.TrimById("Ribbon.Documents.FormActions") ribbon.TrimById("Ribbon.Documents.New.NewFolder") ribbon.TrimById("Ribbon.WikiPageTab") ribbon.TrimById("Ribbon.PublishTab") End If End Sub End Class End Namespace
The Masterpage references it
<%@ Register TagPrefix="SPR" TagName="RibbonItemHider" src="~/_controltemplates/SPR.Utilities/RibbonItemHider.ascx" %>
and then the control is placed in the masterpage body
<SPR:RibbonItemHider id="RibbonItemHider" runat="server"/>
Then we have wrapped this control in the <Sharepoint:SPSecurityTrimmedControl> so for any user who has a certain security level, this ribbon trimming control WON'T be used...at least that's the theory.
Tuesday, January 18, 2011 5:10 PM -
We've hit upon the notion that our <Sharepoint:SPSecurityTrimmedControl> was wrong because we were treating ManageWeb (the permission we had included) as a group and this was wrong as it's a permission. We had a look at some of the properties for this control and see that permissionstring works a collection of permissions. However we are wondering if there is some syntax that would allow us to do the opposite of stating which permissions allow the control within the security trimming to be seen, and instead, which permissions CAN'T see the control.
<SharePoint:SPSecurityTrimmedControl PermissionsString="AddAndCustomizePages, ManageLists" runat="server">
Is there anyway to get some syntax in this PermissionsString property to reverse the process?
Wednesday, January 19, 2011 12:20 PM -
We have overcome this issue by placing a security IF statement in the ribbon trimming control itself.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim ribbon As SPRibbon = SPRibbon.GetCurrent(Me.Page) If ribbon IsNot Nothing And Not (SPContext.Current.Web.CurrentUser.IsSiteAdmin) Then ribbon.TrimById("Ribbon.Library") ribbon.TrimById("Ribbon.Documents.EditCheckout") ribbon.TrimById("Ribbon.Documents.Manage") ribbon.TrimById("Ribbon.Documents.Share") ribbon.TrimById("Ribbon.Documents.Copies") ribbon.TrimById("Ribbon.Documents.Workflow") ribbon.TrimById("Ribbon.Documents.QuickSteps") ribbon.TrimById("Ribbon.Documents.FormActions") ribbon.TrimById("Ribbon.Documents.New.NewFolder") ribbon.TrimById("Ribbon.WikiPageTab") ribbon.TrimById("Ribbon.PublishTab") End If End Sub
- Marked as answer by Ryan Greenaway Wednesday, January 19, 2011 2:20 PM
Wednesday, January 19, 2011 2:20 PM