Archive for November, 2010

Hexadecimal equivalent of SharePoint Base Permissions

Sometimes we need hexadecimal equivalent of SharePoint permission levels. These values can be very useful to make UI changes through JavaScript/JQuery based on current logged-in user’s permission level.
I used the following code in a C# console application to get the hexadecimal equivalent of permission levels:

using System;
using Microsoft.SharePoint;

namespace GetSPBasePermissions
{
class Program
{
static void Main(string[] args)
{
foreach (SPBasePermissions enm in Enum.GetValues(typeof(SPBasePermissions)))
{
string enmName = enm.ToString();
string enumValue = String.Format("0x{1:X}",
enmName, (UInt64)Enum.Parse(typeof(SPBasePermissions), enmName));
Console.WriteLine(enmName + " : " + enumValue);
}
Console.ReadLine();
}
}
}

This program will give the following output:

EmptyMask : 0x0
ViewListItems : 0x1
AddListItems : 0x2
EditListItems : 0x4
DeleteListItems : 0x8
ApproveItems : 0x10
OpenItems : 0x20
ViewVersions : 0x40
DeleteVersions : 0x80
CancelCheckout : 0x100
ManagePersonalViews : 0x200
ManageLists : 0x800
ViewFormPages : 0x1000
Open : 0x10000
ViewPages : 0x20000
AddAndCustomizePages : 0x40000
ApplyThemeAndBorder : 0x80000
ApplyStyleSheets : 0x100000
ViewUsageData : 0x200000
CreateSSCSite : 0x400000
ManageSubwebs : 0x800000
CreateGroups : 0x1000000
ManagePermissions : 0x2000000
BrowseDirectories : 0x4000000
BrowseUserInfo : 0x8000000
AddDelPrivateWebParts : 0x10000000
UpdatePersonalWebParts : 0x20000000
ManageWeb : 0x40000000
UseClientIntegration : 0x1000000000
UseRemoteAPIs : 0x2000000000
ManageAlerts : 0x4000000000
CreateAlerts : 0x8000000000
EditMyUserInfo : 0x10000000000
EnumeratePermissions : 0x4000000000000000
FullMask : 0x7FFFFFFFFFFFFFFF

,

1 Comment