Permissions.AddPermissionCollection Method
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.
Namespace: [Permissions Web service]
Web service reference: http://Site/_vti_bin/Permissions.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddPermissionCollection", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub AddPermissionCollection ( _
objectName As String, _
objectType As String, _
permissionsInfoXml As XmlNode _
)
'Usage
Dim instance As Permissions
Dim objectName As String
Dim objectType As String
Dim permissionsInfoXml As XmlNode
instance.AddPermissionCollection(objectName, _
objectType, permissionsInfoXml)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddPermissionCollection", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void AddPermissionCollection(
string objectName,
string objectType,
XmlNode permissionsInfoXml
)
Parameters
objectName
Type: System.StringA string that contains the name of the list or site.
objectType
Type: System.StringA string that specifies either List or Web.
permissionsInfoXml
Type: System.Xml.XmlNodeAn 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>
Remarks
To access the Permissions service and its methods, set a Web reference to https://Server_Name/[sites/][Site_Name/]_vti_bin/Permissions.asmx.
Examples
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
Dim permService As New Web_Reference_Folder_Name.Permissions()
permService.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim myDocument As New XmlDocument()
myDocument.Load("C:\\File_Name.xml")
Dim ndPermissions As XmlNode = myDocument.DocumentElement
Try
permService.AddPermissionCollection("List_Name", "List", ndPermissions)
Catch ex As System.Web.Services.Protocols.SoapException
MessageBox.Show(ex.Message + ControlChars.Lf + ex.Detail.OuterXml + ControlChars.Lf + ex.StackTrace)
End Try
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);
}