Thursday 26 January 2012

Sharepoint 2007 - showing things per permission level

In Sharepoint 2007 it's common to find a scenario where you need all your users to have read access to the page but then want to display a certain object to users with a different level of permission.

Example:

In my Sharepoint 2007 Environment everyone can view an Announcement but had a requirement to make it easy for content owners to edit an Announcement from the same page.

My Solution was to add an Edit Icon that only users with Contribute level of access for this list can access.

Yes if you add a web part and use 'Audience Targeting' it will essentialy do the same thing but the thing with Audience Targeting is you will most likely have to create a seperate group for this and the web part will have it's limitations.

So How do we do it?
the IfHasRights function is the key, add this code infront of what you are wanting to show to users with a certain permission and it will


 <xsl:if test="ddwrt:IfHasRights(2)">
                yourcodehere


       </xsl:if>

Add the number in the code to what level of permission they require to see the object

ViewListItems - 1
AddListItems - 2
EditListItems - 4
DeleteListItems - 8
ApproveItems - 16
OpenItems - 32
ViewVersions - 64
DeleteVersions - 128
CancelCheckout - 256
PersonalViews - 512
ManageLists - 2048
ViewFormPages - 4096
Open - 65536
ViewPages - 131072
AddAndCustomizePages - 262144
ApplyThemeAndBorder - 524288
ApplyStyleSheets - 1048576
ViewUsageData - 2097152
CreateSSCSite - 4194314
ManageSubwebs - 8388608
CreateGroups - 16777216
ManagePermissions - 33554432
BrowseDirectories - 67108864
BrowseUserInfo - 134217728
AddDelPrivateWebParts - 268435456
UpdatePersonalWebParts - 536870912
ManageWeb - 1073741824
UseRemoteAPIs - 137438953472
ManageAlerts - 274877906944
CreateAlerts - 549755813888
EditMyUserInfo - 1099511627776
EnumeratePermissions - 4611686018427387904
FullMask - 9223372036854775807

No comments:

Post a Comment