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:  WebSvcPermissions
Assembly:  STSSOAP (in STSSOAP.dll)

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.String

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

  • objectType
    Type: System.String

    A string that specifies either List or Web.

  • permissionsInfoXml
    Type: System.Xml.XmlNode

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

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);
}

See also

Reference

Permissions class

Permissions members

WebSvcPermissions namespace