Partilhar via


UserGroup.AddRole Method

Adds a role definition to the current site collection.

Namespace:  [UserGroup Web service]
Web service reference: http://Site/_vti_bin/UserGroup.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddRole", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/directory/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub AddRole ( _
    roleName As String, _
    description As String, _
    permissionMask As Integer _
)
'Usage
Dim instance As UserGroup
Dim roleName As String
Dim description As String
Dim permissionMask As Integer

instance.AddRole(roleName, description, _
    permissionMask)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/directory/AddRole", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/directory/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void AddRole(
    string roleName,
    string description,
    int permissionMask
)

Parameters

  • roleName
    Type: System.String

    A string that contains the name of the role definition.

  • description
    Type: System.String

    A string that contains the description for the role definition.

  • permissionMask
    Type: System.Int32

    A 32-bit integer in 0x00000000 format that represents a Microsoft.SharePoint.SPRights value and specifies permissions for the new role definition. Use the pipe symbol ("|") in Visual C# or Or in Visual Basic to delimit values when creating a custom permission mask that combines permissions.

Examples

The following code example adds a new role definition to the Web site with permissions to both add and delete private Web Parts and to add list items.

Dim usrgrpService As New Web_Reference_Folder_Name.UserGroup()
usrgrpService.Credentials = System.Net.CredentialCache.DefaultCredentials

usrgrpService.AddRole("Group_Name", "Description", &H10000000 Or &H2)
Web_Reference_Folder_Name.UserGroup usrgrpService = new Web_Reference_Folder_Name.UserGroup();
usrgrpService.Credentials= System.Net.CredentialCache.DefaultCredentials;

usrgrpService.AddRole("Group_Name", "Description", 0x10000000|0x00000002);

See Also

Reference

UserGroup Class

UserGroup Members

UserGroup Web Service