Security Trimming WebControls and ASP Objects

I hadn't used this yet, and had cause to this week.  It works slick, and is pretty configurable... I used it to hide the SiteActions button on list pages for members, but not admins, as well as admin web parts embedded in a page.  It works with Web Parts, Web Controls, and other ASP.Net objects (ie. SharePoint:*, etc.).  Wrap the content you want trimmed in the following code (using SPD):

<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="BrowseDirectories">
[Content to Trim]
</Sharepoint:SPSecurityTrimmedControl>

You can then swap out the "BrowseDirectories" with whatever you need for the trimming.  Here are the one's I've found handy so far:

  • BrowseDirectories = Anyone but Limited Read (Anonymous is Limited Read)
  • ManageWeb = Site Collection Admins
  • ManageSubwebs = Site Owners
  • AddListItems = Site Members and specified list contributors

Here's a link to all the defined values in the SPBasePermissions Enum.


Posted on SharePoint Blogs Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Read the complete post at http://www.sharepointblogs.com/echef/archive/2008/01/22/security-trimming-webcontrols-and-asp-objects.aspx

Published Tuesday, January 22, 2008 3:18 PM by SharePoint Blogs
Filed under: ,