Monday, November 9, 2009

You wanna handle page content based on Permissions..!!!.. Tell me....

To start with this post implementation one needs to have a little less known built in XSLT function called ddwrt:IfHasRights()) and some Conditional Formatting logic.
Simply select the text or mark-up inside the data view web part and then
Click on Conditional Formatting option in the Task Panes menu
In the Condition Criteria dialog box select Advanced and in the Advanced Condition dialog box change Select a function category to All
Find and insert the IfHasRights() function by double clicking on the Select a function list
Use a single Permission Mask for example 4 IfHasRights(4) to only make the mark-up or text visible when the user has edit rights on the page\item
Following is a list of Permission Masks for the build in permissions
1. ViewListItems – 1
2. AddListItems – 2
3. EditListItems – 4
4. DeleteListItems – 8
5. ApproveItems – 16
6. OpenItems – 32
7. ViewVersions – 64
8. DeleteVersions – 128
9. CancelCheckout – 256
10. PersonalViews – 512
11. ManageLists – 2048
12. ViewFormPages – 4096
13. Open – 65536
14. ViewPages – 131072
15. AddAndCustomizePages – 262144
16. ApplyThemeAndBorder – 524288
17. ApplyStyleSheets – 1048576
18. ViewUsageData – 2097152
19. CreateSSCSite – 4194314
20. ManageSubwebs – 8388608
21. CreateGroups – 16777216
22. ManagePermissions – 33554432
23. BrowseDirectories – 67108864
24. BrowseUserInfo – 134217728
25. AddDelPrivateWebParts – 268435456
26. UpdatePersonalWebParts – 536870912
27. ManageWeb – 1073741824
28. UseRemoteAPIs – 137438953472
29. ManageAlerts – 274877906944
30. CreateAlerts – 549755813888
31. EditMyUserInfo – 1099511627776
32. EnumeratePermissions – 4611686018427387904
33. FullMask – 9223372036854775807

For example,



Another approach for the same problem set is as follows :

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControlName″ PermissionsString=”” runat=”server”>

The markup that needs to be security trimmed goes here.

</SharePoint:SPSecurityTrimmedControl>
The above mentioned permissions acan be used as trimmer parameter (you can add multiple using commas).