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

GrantAccess Message

CRM 1.2
banner art

Grants a security principal (user or team) access to the specified entity instance.

The relevant classes are specified in the following table.

Type Class
Request GrantAccessRequest
Response GrantAccessResponse
Target TargetOwned Class
Entity See below.

The following table shows the entities and target classes for this message.

Entity Target Class
account TargetOwnedAccount
annotation TargetOwnedannotation
appointment TargetOwnedAppointment
campaign TargetOwnedCampaign
contact TargetOwnedContact
contract TargetOwnedContract
Dynamic entity TargetOwnedDynamic
incident TargetOwnedIncident
invoice TargetOwnedInvoice
lead TargetOwnedLead
list TargetOwnedList
opportunity TargetOwnedOpportunity
quote TargetOwnedQuote
salesorder TargetOwnedSalesOrder
serviceappointment TargetOwnedServiceAppointment
User owned custom entity TargetOwnedX where X is the name of the entity
userquery TargetOwnedUserQuery

Remarks

This action applies to all child objects of the specified entity instance. For all child objects, if the caller does not have share privileges for those object types or share rights to the objects, the child objects are not shared. As a result, the owner of the object or a user who shares the object with share rights automatically has share rights to all child objects of the specified entity instance. In this case, only the lack of privileges for a particular object type prevents the child objects from being shared.

See Cascading Rules for a description of how actions on a parent instance affect child instances.

To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see GrantAccess Privileges.

Example

The following code example shows how to use the GrantAccess message.

[C#]
// Set up the CRM Service.
CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the SecurityPrincipal object.
SecurityPrincipal principal = new SecurityPrincipal();

// Set the properties of the SecurityPrincipal object.
principal.Type = SecurityPrincipalType.User;
// PrincipalId is the GUID of the user to whom 
// access is being granted.
principal.PrincipalId = new Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");

// Create the PrincipalAccess object.
PrincipalAccess principalAccess = new PrincipalAccess();

// Set the properties of the PrincipalAccess object.
principalAccess.Principal = principal;
// Give the principal access to delete.
principalAccess.AccessMask = AccessRights.ReadAccess;
// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// EntityId is the GUID of the account to which access 
// is being granted.
target.EntityId = new Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");

// Create the request object.
GrantAccessRequest grant = new GrantAccessRequest();

// Set the properties of the request object.
grant.PrincipalAccess = principalAccess;
grant.Target = target;

// Execute the request.
GrantAccessResponse granted = (GrantAccessResponse)service.Execute(grant);
[Visual Basic .NET]
' Set up the CRM Service.
Dim service As New CrmService()
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the SecurityPrincipal object.
Dim principal As New SecurityPrincipal()

'Set the properties of the SecurityPrincipal object.
principal.Type = SecurityPrincipalType.User
' PrincipalId is the Guid of the user to whom 
' access is being granted.
principal.PrincipalId = new Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");

' Create the PrincipalAccess object.
Dim principalAccess As New PrincipalAccess()

' Set the properties of the PrincipalAccess object.
principalAccess.Principal = principal
' Give the principal access to delete.
principalAccess.AccessMask = AccessRights.ReadAccess 
' Create the target object for the request.
Dim target As New TargetOwnedAccount()

' EntityId is the GUID of the account to which 
' access is being granted.
target.EntityId = new Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");

' Create the request object.
Dim grant As New GrantAccessRequest()

' Set the properties of the request object.'
grant.PrincipalAccess = principalAccess
grant.Target = target

' Execute the request.
Dim granted As GrantAccessResponse = CType(service.Execute(grant), GrantAccessResponse)

Related Topics

CrmService Messages


© 2007 Microsoft Corporation. All rights reserved.


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