Hiding the SharePoint 2010 Ribbon From Anonymous Users
Guest Author: Kyle Schaeffer
KyleSchaeffer.com
The user interface improvements in SharePoint 2010 as a whole are truly amazing. Microsoft has brought this already impressive product leaps and bounds in terms of accessibility, standards, and usability. One thing you might be aware of is the new and quite useful “ribbon” control that appears by default at the top of every SharePoint 2010 master page. Here’s a sneak peek:

You’ll see this ribbon not only in the 2010 web interface, but also throughout the entire family of Office products coming out this year. Even SharePoint Designer 2010 makes use of the ribbon in a very flexible and useful way.
Hiding the Ribbon
In SharePoint 2010, the ribbon is used almost exclusively for content creation and site administration. It doesn’t make much sense to show the ribbon on a public-facing internet site (in fact, it can really retract from your site’s design when it appears), so you’ll probably want to hide the ribbon when users aren’t logged in. Here’s how it works:
<SharePoint:SPSecurityTrimmedControl PermissionsString="ManagePermissions" runat="server"> <div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle"> <!-- Ribbon code appears here... --> </div> </SharePoint:SPSecurityTrimmedControl>
In your master page, find the SharePoint ribbon by looking for the line of code that begins with <div id=”s4-ribbonrow”>. Place the SPSecurityTrimmedControl code around your ribbon to conditionally hide it based on user permissions. In our example, we’ve hidden the ribbon from any user who doesn’t have the ManagePermissions ability, which is going to be almost any user short of a site administrator.
Other Permission Levels
You can specify different permission levels for the SPSecurityTrimmedControl, allowing you to configure exactly who can see the SharePoint 2010 ribbon. Basically, this control will hide anything inside of it when users don’t have the specified PermissionString. The available options include:
- List Permissions
- ManageLists
- CancelCheckout
- AddListItems
- EditListItems
- DeleteListItems
- ViewListItems
- ApproveItems
- OpenItems
- ViewVersions
- DeleteVersions
- CreateAlerts
- ViewFormPages
- Site Permissions
- ManagePermissions
- ViewUsageData
- ManageSubwebs
- ManageWeb
- AddAndCustomizePages
- ApplyThemeAndBorder
- ApplyStyleSheets
- CreateGroups
- BrowseDirectories
- CreateSSCSite
- ViewPages
- EnumeratePermissions
- BrowseUserInfo
- ManageAlerts
- UseRemoteAPIs
- UseClientIntegration
- Open
- EditMyUserInfo
- Personal Permissions
- ManagePersonalViews
- AddDelPrivateWebParts
- UpdatePersonalWebParts
You can use this control to hide anything in your master page or on related page layouts, so be sure to keep it in mind when you’re trying to hide/show things conditionally based on user permission.
The One Catch
You may notice that the login control (or welcome control) is actually inside the ribbon by default in SharePoint 2010. You’ll probably want to pull this control out of the ribbon and place it elsewhere on your page. Just look for the line of code that looks like this:
<wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"/>
Move this code out of the ribbon and into another location within your master page. Save your changes, check in and approve all files, and anonymous users will never know your site is built on SharePoint 2010!
Guest Author: Kyle Schaeffer
KyleSchaeffer.com
Kyle is a designer, speaker, and blogger living in Williamsburg, Virginia. He is a Senior SharePoint Consultant at SusQtech, where he has years of experience creating and implementing user experiences on the SharePoint platform. An advocate of simple and elegant web design, Kyle shares lessons learned and best practices on his blog, KyleSchaeffer.com.
Will this method also prevent the ribbon scripts from loading if users are not logged in?
Hi, Cristophe. I actually recently found a solution to the problem you’re describing. Check out the updated post here:
http://www.thesug.org/Blogs/kyles/archive/2010/4/21/HidingtheSharePoint2010RibbonFromAnonymousUsers.aspx
Sorry read your question a little too fast. Disregard my previous comment.
Yes, this is actually a server-side control, so it should prevent any ribbon-related requests from loading for anonymous users (ribbon scripts, control behavior, rich text editor CSS, etc.).
ok, I’ll give it a try. Very nice tip, especially as you included all the available permission levels. Thanks!
Hi, folks. I actually updated this post just a few days ago! I found a problem that can sometimes occur if you are using a ribbon that is fixed to the browser window (i.e. the ribbon scrolls as you scroll the page). It’s only a minor change, but it will save you some trouble if you have been following my post and ran into any issues. Find it here:
http://goo.gl/529lc
hello kyle
thank you for that blog post. The permisison trimmed approach is a very useful one – also to other masterpage sections applicable.
it is getting more tricky if you want to hide tabs/groups or simple icons from the ribbon. Is it possibly to hide/remove icons on a non-programmatic approach (eg. javascript on load)?
bye m.
Marvin, you can use jQuery to do a lot of neat things in SharePoint, but I generally opt for the server-side approach to “hiding” things when it’s available. Even if you hide things using JavaScript people can still get to those features, so if you don’t want them to see or use something, it’s best to remove it from the document’s HTML altogether.
hi kyle,
thank for your reply – understand. i will have a look at the jquery method. do you know if there are any tutorials on the web?
thankyou!
I can’t get the login control to be visible for anonymous users when it’s move outside the ribbon scope! (?)
I have added a link to ” /_layouts/authenticate.aspx” instead, but how do I hide this link, when the user is actually logged in?
Hi, Lars. As mentioned in my post above, you’ll want to MOVE the wssuc:Welcome control outside of the ribbon so that anonymous users may log in. This control, when used, will automatically change (so that it no longer says “Sign In”) once a user has been authenticated.
Hi Kyle,
Thanks heaps for the post. Just got a question re the scrolling issues you updated the post with.
You make the comment – “just add a bit of CSS to make the ribbon height automatically shrink if no content appears”
What is that css… if you don’t mind me asking?
Cheers,
Claudio
Hi, Claudio. Check out the section titled “The CSS” on my blog post, which can be found here:
http://goo.gl/529lc
Thanks for that.
So simple in the end…. I feel a bit silly.
Cheers
Hey Kyle, Thanks for the post. It worked for me.
Ankit
hi,
one question
after applying the code to v4.master file in sharepoint 2010 foundation, the ribbon is hide for anonymous user , but i don’t have vertical scroll bar on main page.
How can i fix this?
Thanks
Hi, Romeo. Check out my updated post here for the scrolling fix:
http://www.thesug.org/Blogs/kyles/archive/2010/4/21/HidingtheSharePoint2010RibbonFromAnonymousUsers.aspx