Search code examples
c#sharepoint-2010enumsbitwise-or

What is the result of this C# Bitwise-OR?


I am trying to check permissions for SharePoint users in c# and I came across the following code that seems to work:

isGranted = spweb.DoesUserHavePermissions(userlogin, SPBasePermissions.EmptyMask | SPBasePermissions.ViewPages);

The first argument is the user to check a permission of. The second argument is the permission to check if the user has.

My question is, what is the result of the bitwise-or between emptymask and viewpages permissions? What permission is this actually checking against?


Solution

  • Since EmptyMask is defined as zero, the result is the same as passing the SPBasePermissions.ViewPages with no EmptyMask:

    [Flags]
    public enum SPBasePermissions
    {
        EmptyMask =                 0×0000000000000000,
        ...
    }