Permissions.AddPermission Method

Modifies site-level permissions for the site group that exists on the site, or adds or modifies permissions to the specified list for the user, site group, or cross-site group that exists on the site.

Web Service: PermissionsWeb Reference: http://<Site>/_vti_bin/Permissions.asmx

Syntax

<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddPermission", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/directory/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Sub AddPermission ( _
    objectName As String, _
    objectType As String, _
    permissionIdentifier As String, _
    permissionType As String, _
    permissionMask As Integer _
)

Dim instance As Permissions
Dim objectName As String
Dim objectType As String
Dim permissionIdentifier As String
Dim permissionType As String
Dim permissionMask As Integer

instance.AddPermission(objectName, objectType, permissionIdentifier, permissionType, permissionMask)
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddPermission", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public void AddPermission (
    string objectName,
    string objectType,
    string permissionIdentifier,
    string permissionType,
    int permissionMask
)

Parameters

  • objectName
    A string that contains the name of the list or site.
  • objectType
    A string that specifies either List or Web.
  • permissionIdentifier
    A string that contains the name of the site group, the name of the cross-site group, or the user name (DOMAIN\User_Alias) of the user to whom the permission applies.
  • permissionType
    A string that specifies user, group (cross-site group), or role (site group). The user or cross-site group has to be valid, and the site group has to already exist on the site.
  • permissionMask
    A 32-bit integer in 0x00000000 format that represents a Microsoft.SharePoint.SPRights value and defines the permission. Use the pipe symbol ("|") in C# or Or in Microsoft Visual Basic to delimit values when creating a custom permission mask that combines permissions.

Remarks

To access the Permissions service and its methods, set a Web reference to http://Server_Name/[sites/][Site_Name/]_vti_bin/Permissions.asmx.

Example

The following code example adds or modifies permissions to a list for an existing cross-site group.

Dim permService As New Web_Reference_Folder_Name.Permissions()
permService.Credentials = System.Net.CredentialCache.DefaultCredentials

permService.AddPermission("List_Name", "List", "Group_Name", "group", &H2 Or &H400)
Web_Reference_Folder_Name.Permissions permService = new Web_Reference_Folder_Name.Permissions();
permService.Credentials= System.Net.CredentialCache.DefaultCredentials;

permService.AddPermission("List_Name", "List", "Group_Name", "group", 0x00000002 | 0x00000400);

See Also

Reference

Permissions Class
Permissions Members
Permissions Web Service