Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

AddPrivilegesRole Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Adds a set of existing privileges to an existing role.

The relevant classes are specified in the following table.

TypeClass
RequestAddPrivilegesRoleRequest
ResponseAddPrivilegesRoleResponse
Entityrole

Remarks

To use this message, pass an instance of the request class as the AddPrivilegesRoleRequest parameter in the Execute method.

To perform this action, the caller must have access rights on the role entity instance. For a list of required privileges, see AddPrivilegesRole Privileges.

The privileges are defined in the RolePrivilege class.

Example

The following code example demonstrates how to add a set of existing privileges to an existing role.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory Authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

      const string PRVAPPENDTOSITE = "B7A1F52A-B8A9-11D8-84AB-0007E9E100CC";

// Create the RolePrivileges.
RolePrivilege[] privileges = new RolePrivilege[1];

// Set the RolePrivileges properties.
privileges[0] = new RolePrivilege();
privileges[0].PrivilegeId = new Guid(PRVAPPENDTOSITE);
privileges[0].Depth = PrivilegeDepth.Global;

// Create the request object.
AddPrivilegesRoleRequest add = new AddPrivilegesRoleRequest();

// Set the properties of the request object.
add.Privileges = privileges;
add.RoleId = new Guid("C15AF217-C17E-DA11-B90F-000874DE7397");
   
// Execute the request.
AddPrivilegesRoleResponse booked = (AddPrivilegesRoleResponse)service.Execute(add);
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

      const PRVAPPENDTOSITE as String = "B7A1F52A-B8A9-11D8-84AB-0007E9E100CC"

' Create the RolePrivileges.
Dim privileges(0) As RolePrivilege

' Set the RolePrivileges properties.
privileges(0) = New RolePrivilege()
privileges(0).PrivilegeId = New Guid(PRVAPPENDTOSITE)
privileges(0).Depth = PrivilegeDepth.[Global]

' Create the request object.
Dim add As New AddPrivilegesRoleRequest()

' Set the properties of the request object.
add.Privileges = privileges
add.RoleId = New Guid("C15AF217-C17E-DA11-B90F-000874DE7397")

' Execute the request.
Dim booked As AddPrivilegesRoleResponse = CType(service.Execute(add), AddPrivilegesRoleResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.