SPSecurityTrimmedControl and PermissionsString

You shall sooner or later face a situation that you need to create a control under specific (custom) permission levels. SPSecurityTrimmedControl is one control that can give you such features.

A simple SPSecurityTrimmedControl can be added to you page as shown below:

<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="XYZ">
</Sharepoint:SPSecurityTrimmedControl>

Now, the XYZ can be any of the following as mentioned below.

Scenario: If I need to give specific users permissions to Edit the page; I use below lines of code...

<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="AddAndCustomizePages">
<div>
<a href="javascript:MSOLayout_ToggleLayoutMode();">Edit Page</a>
</div>
</Sharepoint:SPSecurityTrimmedControl>

Which means any user who belongs to a group with permissions for 'Adding and Customozing the Pages' can see the hyperlink Edit Page.
_____________________________________________________________________
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

Comments

Anonymous said…
Whenever this control is added, SharePoint designer strips the code out when saving. Is this no longer supported?
Srini Sistla said…
What are you trying to secure? On certain list (such as User Information List etc) if you try to apply, SPD will trim it automatically. It is supported in 2007 and I haven't experienced any issues so far. Not sure if SP2 has any bug.
Anonymous said…
Thanks for the quick response. I'm trying to secure a calendar. I created a new web zone for the calendar. I was trying to place the SPSecurityTrimmedControl inside the zone tag and it disappeared on save. Is that an invalid location? The control seems to work outside the zone tag.
darrindickey said…
This comment has been removed by the author.
darrindickey said…
I had the same issue when trying to use a ManagePermission security trim. I had to add the security trim code outside of the web part zone to make it work.
Anonymous said…
Did anybody figure out this yet? When added to wrap a WebPartPages:ListViewWebPart webpart in SPD 2007 and save, it's gone!