Permissions Webservice and the Mask Attribute

With the SharePoint Permissions Webservice you can get the Permissions from a List or Web. The Webservice returns information like this example from the WSS SDK:

 1: <GetPermissionCollection xmlns=http://schemas.microsoft.com/sharepoint/soap/directory/">

<span class=lnum>   2:  </span>   <Permissions>
 3:  "1073741829" Mask="-1" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>   4:  </span>         RoleName=<span class=str>"Administrator"</span> />
 5:  "1073741828" Mask="1029638927" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>   6:  </span>         RoleName=<span class=str>"Web Designer"</span> />
 7:  "1073741827" Mask="1027801615" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>   8:  </span>         RoleName=<span class=str>"Contributor"</span> />
 9:  "1073741826" Mask="138608641" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>  10:  </span>         RoleName=<span class=str>"Reader"</span> />
 11:  "1073741825" Mask="134283264" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>  12:  </span>         RoleName=<span class=str>"Guest"</span> />
 13:  "1073741830" Mask="134414337" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>  14:  </span>         RoleName=<span class=str>"Site_Group1"</span> />
 15:  "1073741831" Mask="134283265" MemberIsUser="False" MemberGlobal="False" 
<span class=lnum>  16:  </span>         RoleName=<span class=str>"Site_Group2"</span> />
 17:  .
<span class=lnum>  18:  </span>         .
 19:  .
<span class=lnum>  20:  </span></GetPermissionCollection>

 

If you want to convert the Mask to readable SPBasePermissions objects, the answer is:

 1: SPBasePermissions permissions = 

<span class=lnum>   2:  </span>(SPBasePermissions) Enum.Parse(<span class=kwrd>typeof</span> (SPBasePermissions), permissionMask.ToString());

 

Quite simple. Isn’t it?

Keywords: SharePoint, Webservice, Permissions, Mask, GetPermissionCollection