Ok, so this turned out not to be so custom, but it was annoying enough to figure it out that I wanted to share.
My problem: I've created some custom widgets in my master page, but I only want Full Control people and Contributors to see them, not Readers, etc. So, I tried to use the SPRole to figure out what roles the current user was in. It didn't work as expected, plus it's depricated. So I moved on to the SPRoleDefinition and SPRoleAssignment classes. These also didn't give me what I wanted. Finally I did a search on tapping into SharePoint's security trimming, and found this gem.
Wrap the following tag around the thing that you want security trimmed, and SharePoint will take care of it for you.
< SharePoint:SPSecurityTrimmedControl id="something" runat="server" PermissionsString="AddAndCustomizePages"> your stuff goes here < /SharePoint:SPSecurityTrimmedControl>
The important bit is what goes inside the PermissionsString attribute.
Here's a list of possible values:
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
No comments:
Post a Comment