1,804 articles and 15,022 comments as of Sunday, January 23rd, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint (Joel Oleson) content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Tuesday, November 9, 2010

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.

 

Please Join the Discussion

15 Responses to “Hiding the SharePoint 2010 Ribbon From Anonymous Users”
  1. Christophe says:

    Will this method also prevent the ribbon scripts from loading if users are not logged in?

  2. 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

  3. marvin says:

    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.

      • marvin says:

        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!

  4. 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.

  5. Claudio says:

    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

  6. ankit khandekar says:

    Hey Kyle, Thanks for the post. It worked for me.

    Ankit

Trackbacks

Check out what others are saying about this post...
  1. Novell Enters Enterprise Collaboration Market; Microsoft Previews Lync at TechEd; Hands-On with Google Instant Previews…

    Top News Stories Novell Unveils Enterprise Collaboration Platform Beta (Computerworld) Novell today took…




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!