Skip to main content

Hiding the Site Actions Menu for certain users

While working on a client site recently I was asked to hide the site actions menu and only allow certain users to view it. After a bit of digging around and searching I found the answer to be the “SPSecurityTrimmedControl”. Now the great thing about this control is that it only renders the contents of the controls it contains if the user has a matching permission level. Therefore the only thing I needed to do was create myself a custom permission level called “DisplaySiteActionsMenu” and assign that to the group or groups who should see the site actions menu. Once this was done all the standard users to the site didn't even know the site actions menu existed.

Below is an example of how I updated the master page for the site to make this work.

<SharePoint:SPSecurityTrimmedControl ID="stcHideMasterPageItems" PermissionsString="DisplaySiteActionsMenu">

<PublishingSiteAction:SiteActionMenu runat="server"/>

</SharePoint:SPSecurityTrimmedControl>

Comments

Popular posts from this blog

Shouldn’t validating a checkbox be easier than this?

  Well it's been a while since I have done a post but with changing jobs recently and life in general getting in the way I just couldn’t seem to find the time. However, now I have a spare five minutes I thought I would fire off a post :) So what's the post about? Validating a checkbox web control. Now I know your reading this thinking that's easy all you need is a custom validator and a event handler in your code behind and job done? Well in most cases yes I would agree with you. However, my latest project (a legacy application) uses code generation to create the vast majority of the ASP.NET pages and user controls. Therefore it’s difficult for me to include anything other than the standard set of ASP.NET validators or something which inherits off the “ BaseValidator ” and get it working correctly in the XSLT templates generating the code. Because of this I decided to create my own validator for the checkbox web control. So how do we get started? Well first off you ne...

SharePoint - Search Service Application (SSA) - Attempted to perform an unauthorized operation

On my current project I needed to adjust and add some search mapping via SharePoint's Central Administration web site. This should have been very straight forward as you have the ability to add managed properties and mappings easily via the UI. However, when I went to save my changes I got the error "The settings could not be saved because of an internal error: Attempted to perform an unauthorized operation". Now this was very confusing as I am administrator on the server and added into all of the correct SharePoint groups. I also tried the same action via PowerShell and got the same error.   After a few hours of research and head scratching I managed to get to the bottom of the problem which is the way my user account had been added as an administrator to the server. In the company I work for to make it easier to manage the administrators on a server a group is created in active directory called " servername_admins ". This group is added to the local administra...

Bob the builder

I recently started a new project which is very focused on having good test coverage which is great goal to have.  However, looking through their tests I started to notice a lot of setup code which was very similar and looked a lot like the following: 1: [TestMethod] 2: public void WhenTheAddressRepositoryIsAskedToAPersistAddressesItShouldCorrectlyPersistThoseAddresses() 3: { 4: // Arrange 5: var addressesToPersist = new List<Address>(); 6:   7: var address = new Address 8: { 9: AddressLine1 = Guid.NewGuid().ToString(), 10: AddressLine2 = Guid.NewGuid().ToString(), 11: AddressLine3 = Guid.NewGuid().ToString(), 12: AddressLine4 = Guid.NewGuid().ToString(), 13: ...