Partilhar via


Hide Ribbon for Anonymous users SharePoint 2013

 

You might have thought to hide Ribbon from the Anonymous users due to security reason,

In SharePoint 2010 it was simple to modify the master page and that's done, In SharePoint 2013 there has been some changes and we no more need to modify the master page directly, every thing is simplified in 2013 and we just need to modify the concern html page and that should be done.

 

Every master page in 2013 would have it concerned html page eg for Seattle.master we have Seattle.html

for oslo.master we have oslo.html page  which in turn controls the master page and its tags.

Html page has tags that start with <!--MS:--> and <!--ME:--> that show markup inside these tags and in some cases what you would find in the final corresponding master page.

So lets get to the action on what need to done in these html page.

1. Open the html page in SharePointDesigner 2013 or open the site through explorer and open it using your favorite html page editor.

2. Look for <Div Class =”ms-belltown-anonshow”>

<div id=”ms-designer-ribbon”>

…..

</div>

3. When we add the following markup enclosed in the <!--MS:--> and <!--ME:—> tags,

<!—MS:<SharePoint:SpSecurityTrimmedControl runat=”server” permission=”AddandCustomizepages”>—>

<Div Class =”ms-belltown-anonshow”>

<div id=”ms-designer-ribbon”>

….

</div>

<!—MS:</SharePoint:SpSecurityTrimmedControl>—>

the design manager will create the corresponding master page with the correct functionality of hiding the Ribbon for an anonymous user.

For list of permission you can refer to

https://msdn.microsoft.com/en-ca/library/microsoft.sharepoint.spbasepermissions.aspx

Technorati Tags: Hide Ribbon,SharePoint 2013,maste page

Technorati Tags: Hide Ribbon,SharePoint 2013,maste page

Comments

  • Anonymous
    June 19, 2013
    Hii, I tried to use this snippets but failed to get Scrollbar for anonymous users.

  • Anonymous
    June 20, 2013
    Hi, the method will work but there is a much better way to accomplish this. SPSecurityTrimmedControl have a property called AuthenticationRestriction which have the following values:

  • AllUsers Access is available to all users.

  • AuthenticatedUsersOnly Access is available only to authenticated users.

  • AnonymousUsersOnly       Access is available only to anonymous users. msdn.microsoft.com/.../microsoft.sharepoint.webcontrols.spsecuritytrimmedcontrol.authenticationrestrictions.aspx This will work since SharePoint 2010. /greetings Stefan

  • Anonymous
    October 25, 2013
    Hi, This solution effectively remove the ribbon, but adds other problems to site such as not calculate the dimensions of s4-workspace element, and does not maintain the scroll position because _maintainWorkspaceScrollPosition field is disabled. Apparently the ribbon performs other functions other than displaying options

  • Anonymous
    November 18, 2013
    You have an error in your example. Where you have <!—MS:</SharePoint:SpSecurityTrimmedControl>—> it should be <!—ME:</SharePoint:SpSecurityTrimmedControl>—> i.e. It shouldn't be markup start, it should be markup end when closing off the tag.

  • Anonymous
    March 10, 2014
    To John's point, we have used the trimmedcontrol slightly different, we initiate the ribbon with display:none property and use trimmedcontrol to emit the javascript to display it via jQuery. This way the height calculations seem to work ok with SharePoint.

  • Anonymous
    April 01, 2014
    Has anyone been able to implement this, without losing the ability to be able to scroll down the page? This works fine for hiding the ribbon, but, there is no ability to scroll down the page.

  • Anonymous
    April 15, 2014
    This method may be recommended by Microsoft, but it breaks OOTB functionality of a masterpage (as said by John Olivera) s4-workspace is not calculated.
    This is not a proper way of doing things.