"Out of the box" there are no "deny permission" features in SharePoint, only grant permissions. If you have a group called Sales with 1000 users, and you would like to use the SharePoint Audience feature to display a web part for everyone in Sales except for Sam, Susan and Bob, you will have to create a new group with 997 users named "Sales except for Sam, Susan and Bob" (and then maintain two groups going forward. But there is a way…
Here's a trick that starts by using a Content Editor Web Part to hide another web part from everyone. By creating a group with our three problem people and using that as an Audience for this CEWP we can selectively hide another web part.
Before we start, Audiences are not available in WSS 3.0 (2007) or SharePoint 2010 Foundation.
For this trick you need to do four things:
- Create the group or audience of people to hide things from
- Discover the ID of the web part you want to hide (see here for 2007 and 2010)
- Write a bit of CSS to hide the web part
- Add a Content Editor Web Part to hold or link to the CSS and audience filter it
Create the audience:
Your audience can be any AD group (Distribution/Security Group), any SharePoint group you create or a custom audience (Global Audiences) created by your server administrator. For testing proposes you make want to create a test SharePoint group named "TheNoSeeGroup".
The CSS is quite simple, just a "display:none" to hide the entire web part. As this will placed in a Content Editor Web Part that will only be seen by the "TheNoSeeGroup" this CSS will only be effective for those users. The trick here is to get the ID of the web part you want to hide.
Discovering the ID of the web part to hide:
Go to the page with the web part to hide (such as Shared Documents) and use your browser's View Source option to see the page's HTML. Do a search for MSOZoneCell_WebPart and browse around to see if there's any hints that your found the right web part. If not, search again. For more help, go her for 2007 and here 2010. The ID will look something like MSOZoneCell_WebPart9. Note that if you delete and re-add the web part it may receive a new number.
- Find your web part's ID (MSOZoneCell_WebPart1, MSOZoneCell_WebPart2, etc)
- Open Notepad and add the CSS from above using your web part's ID
- Save the Notepad file and upload to a SharePoint library in your site (I used Site Assets and named the file HideWebPart.htm)
- Go to the library where you loaded the file, right-click the file and select Copy Shortcut (or better, right-click the file, click Properties and copy the URL from there)
- Go to the page with the web part you want to hide, edit the page and add a Content Editor Web Part (CEWP) above the web part you want to hide
- Edit the CEWP and paste the URL copied earlier for the CSS Notepad file
- Click OK… The Shared Documents web part should now be hidden (from everyone!)
- Edit the Content Editor Web Part again
- In the web part's properties panel expand the Advanced section, scroll to the bottom and select the audience to hide the web part from
Note that in 2010 the text box has no visible border!
- Save your changes and test by have a group member, and a non-group member, log in and see if the web part is displayed.
Note for 2010: If you can't see the CEWP when you edit the page (to edit it or to delete it) it's because you are not in the right group! Either add yourself to the "hide from" group or use a trick from here to display a list of all of the web parts, append ?Contents=1 or &Contents=1 to the end of the page's URL.