SharePoint 2010 Check permissions using XSLT

At my starting page i displayed documents and an upload link to upload a document. If a user has read access, he also see the upload link. But i would like to have it like the “add new item” link below the normal list views – only the user with the right access permission can add new items. So what can be done? Using javascript? I asked google and google gave me the hint to look into this post from Scott Hatcher, in which he wrote about Conditionally Format XSLT Based on User Permissions. I tried and it works like charm for me.

Just insert a snippet of code around your upload link which look like this:

<xsl:if test="ddwrt:IfHasRights(2)">
<!-- Display upload link or not -->

If you want to use other permissions like delete or anything, you just have to change the number at IfHasRights(XX). See the following table.

Permission Code
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


The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Schneider
About Karsten Schneider 302 Articles
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.