This topic has not yet been rated - Rate this topic

Permissions.AddPermissionCollection Method

Windows SharePoint Services 3
Modifies site-level permissions for the specified collection of existing site groups, or adds or modifies permissions to the list for the specified collection of existing users, site groups, and cross-site groups.

Web Service: PermissionsWeb Reference: http://<Site>/_vti_bin/Permissions.asmx
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/directory/AddPermissionCollection", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/directory/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public void AddPermissionCollection (
	string objectName,
	string objectType,
	XmlNode permissionsInfoXml
)

Parameters

objectName

A string that contains the name of the list or site.

objectType

A string that specifies either List or Web.

permissionsInfoXml

An XML fragment in the following format that specifies the permissions to add and that can be passed as a System.Xml.XmlNode object:

<Permissions>
  <Users>
     <User LoginName=
       "DOMAIN\User_Alias" 
       Email="Email_Address" 
       Name="Display_Name" 
       Notes="Notes" 
       PermissionMask="138608641" />
       .
       .
       .
  </Users>
  <Groups>
     <Group GroupName=
       "Cross-site_Group" 
       PermissionMask=
       "1027801615" />
      .
      .
      .
   </Groups>
   <Roles>
      <Role RoleName="Site_Group" 
        PermissionMask="-1" />
      .
      .
      .
   </Roles>
</Permissions>

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

The following code example modifies the permissions to a list for the specified collection of existing users, site groups, and cross-site groups. The example assumes the existence of a local XML file that contains information about the users and groups, which is loaded into a System.Xml.XmlDocument object. This example requires that a using (C#) or Imports (Microsoft Visual Basic) directive be included for the System.Xml namespace

Web_Reference_Folder_Name.Permissions permService = new Web_Reference_Folder_Name.Permissions();
permService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlDocument myDocument = new XmlDocument();
myDocument.Load("C:\\\\File_Name.xml");

XmlNode ndPermissions = myDocument.DocumentElement;

try
{
   permService.AddPermissionCollection("List_Name", "List", ndPermissions);
}

catch (System.Web.Services.Protocols.SoapException ex)
{
   MessageBox.Show(ex.Message + " \n::\n " + ex.Detail.OuterXml + " \n::\n " + ex.StackTrace);
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ