Checking Permissions with Javascript in Sharepoint 2007

28 October 2010

If you'll remember in my previous Sharepoint post regarding ECB customization, I was working on a custom Version History page. One of the modifications I finished today was changing the ECB for our custom Version History page to require additional permissions (in addition to the Delete Version permission) before displaying the Delete option in the ECB for that page.

To do so, we just need to check the current user permissions with the HasRights() javascript method defined in core.js, which takes two parameters - the low permission string mask, and the high permission string mask, returning a boolean indicating whether or not the user has the correct permissions. I didn't quite understand the low permission string mask (it might be for reverse operations or something like that), but the following javascript shows a message if the user is allowed to delete versions:

if(HasRights(0x0, 0x80))
    alert("You have rights to delete versions.");

A full list of the permissions masks can be found here.

Tags: Javascript, permissions, sharepoint 2007

Add a Comment

No Comments