Share via


GrantAccessRequest Class

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

Contains the data that is needed to grant a security principal (user or team) access to the specified record.

Namespace: Microsoft.Crm.Sdk.Messages
Assembly: Microsoft.Crm.Sdk.Proxy (in Microsoft.Crm.Sdk.Proxy.dll)

Syntax

'Declaration
<DataContractAttribute(Namespace:="https://schemas.microsoft.com/crm/2011/Contracts")> _
Public NotInheritable Class GrantAccessRequest
    Inherits OrganizationRequest
[DataContractAttribute(Namespace="https://schemas.microsoft.com/crm/2011/Contracts")] 
public sealed class GrantAccessRequest : OrganizationRequest

Example

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.

// Grant the team read/write access to the lead.
var teamReference = new EntityReference(Team.EntityLogicalName, _teamId);
var grantAccessRequest = new GrantAccessRequest
{
    PrincipalAccess = new PrincipalAccess
    {
        AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess,
        Principal = teamReference
    },
    Target = leadReference
};

Console.WriteLine("Granting {0} to {1} ({2}) on the lead...\r\n",
    AccessRights.ReadAccess | AccessRights.WriteAccess, GetEntityReferenceString(teamReference), "Team");
_serviceProxy.Execute(grantAccessRequest);

var systemUser2Ref = new EntityReference(SystemUser.EntityLogicalName,
    _systemUserIds[1]);
' Grant the team read/write access to the lead.
Dim teamReference = New EntityReference(Team.EntityLogicalName,
                                        _teamId)

Dim grantAccessRequest1 = New GrantAccessRequest With
                         {
                             .PrincipalAccess =
                             New PrincipalAccess With
                             {
                                 .AccessMask = AccessRights.ReadAccess Or AccessRights.WriteAccess,
                                 .Principal = teamReference
                             },
                             .Target = leadReference
                         }

Console.WriteLine("Granting {0} to {1} ({2}) on the lead..." & vbCrLf,
                  AccessRights.ReadAccess Or AccessRights.WriteAccess, GetEntityReferenceString(teamReference),
                  "Team")
_serviceProxy.Execute(grantAccessRequest1)

Remarks

Message Availability

For this message to work, the caller must be connected to the server.

Usage

Pass an instance of this class to the Execute method, which returns an instance of the GrantAccessResponse class.

Privileges and Access Rights

To perform this action, the caller must have privileges on the specified entity in the Target property and access rights on the specified record in the Target property. For a list of the required privileges, see GrantAccess Privileges.

Notes for Callers

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

For a description of how actions on a parent instance affect child records, see Cascading Behavior.

Supported Entities

The following table shows the default entities that support this message. For the listed entities, the caller must be connected to the server for this message to be available.

Entity Availability

account

Server

annotation

Server

appointment

Server

campaign

Server

campaignactivity

Server

campaignresponse

Server

connection

Server

contact

Server

contract

Server

customeropportunityrole

Server

customerrelationship

Server

duplicaterule

Server

email

Server

emailserverprofile

Server

fax

Server

goal

Server

goalrollupquery

Server

import

Server

importfile

Server

importmap

Server

incident

Server

incidentresolution

Server

invoice

Server

lead

Server

letter

Server

list

Server

mailbox

Server

mailmergetemplate

Server

opportunity

Server

opportunityclose

Server

orderclose

Server

phonecall

Server

processsession

Server

queue

Server

quote

Server

quoteclose

Server

recurringappointmentmaster

Server

report

Server

salesorder

Server

serviceappointment

Server

sharepointdocumentlocation

Server

sharepointsite

Server

task

Server

template

Server

userform

Server

userquery

Server

userqueryvisualization

Server

workflow

Server

Inheritance Hierarchy

System.Object
   Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Crm.Sdk.Messages.GrantAccessRequest

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Server 2008, Windows Server 2012, Windows 7 (All Versions), Windows 8 (All Versions)

Target Platforms

Windows Server 2008, ,Windows Server 2012, ,Windows 7 (All Versions),

Change History

See Also

Reference

GrantAccessRequest Members
Microsoft.Crm.Sdk.Messages Namespace
Actions on Entity Records
GrantAccessResponse

Other Resources

How Record-Based Security Can Be Used to Control Access to Records In Microsoft Dynamics CRM
Sample: Share Records Using GrantAccess, ModifyAccess and RevokeAccess Messages

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.