Partilhar via


GrantAccessRequest Class

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, 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)

Inheritance Hierarchy

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

Syntax

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

Constructors

Name Description
System_CAPS_pubmethod GrantAccessRequest()

Initializes a new instance of the GrantAccessRequest class.

Properties

Name Description
System_CAPS_pubproperty ExtensionData

Gets or sets the structure that contains extra data. Optional.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Item[String]

Gets or sets the indexer for the Parameters collection.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty PrincipalAccess

Gets or sets the team or user that is granted access to the specified record. Required.

System_CAPS_pubproperty RequestId

Gets or sets the ID of an asynchronous operation (system job). Optional. (Inherited from OrganizationRequest.)

System_CAPS_pubproperty RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Target

Gets or sets the entity that is the target of the request to grant access. Required.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

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 message 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

0 (Server)

Annotation

0 (Server)

Appointment

0 (Server)

Campaign

0 (Server)

CampaignActivity

0 (Server)

CampaignResponse

0 (Server)

Connection

0 (Server)

Contact

0 (Server)

Contract

0 (Server)

ConvertRule

0 (Server)

CustomerOpportunityRole

0 (Server)

CustomerRelationship

0 (Server)

DuplicateRule

0 (Server)

Email

0 (Server)

EmailServerProfile

0 (Server)

Entitlement

0 (Server)

Fax

0 (Server)

Goal

0 (Server)

GoalRollupQuery

0 (Server)

Import

0 (Server)

ImportFile

0 (Server)

ImportMap

0 (Server)

Incident

0 (Server)

IncidentResolution

0 (Server)

Invoice

0 (Server)

Lead

0 (Server)

Letter

0 (Server)

List

0 (Server)

Mailbox

0 (Server)

MailMergeTemplate

0 (Server)

msdyn_PostAlbum

0 (Server)

msdyn_wallsavedqueryusersettings

0 (Server)

Opportunity

0 (Server)

OpportunityClose

0 (Server)

OrderClose

0 (Server)

PhoneCall

0 (Server)

ProcessSession

0 (Server)

Queue

0 (Server)

Quote

0 (Server)

QuoteClose

0 (Server)

RecurringAppointmentMaster

0 (Server)

Report

0 (Server)

RoutingRule

0 (Server)

SalesOrder

0 (Server)

ServiceAppointment

0 (Server)

SharePointDocumentLocation

0 (Server)

SharePointSite

0 (Server)

SLA

0 (Server)

SLAKPIInstance

0 (Server)

SocialActivity

0 (Server)

SocialProfile

0 (Server)

Task

0 (Server)

Template

0 (Server)

UserForm

0 (Server)

UserQuery

0 (Server)

UserQueryVisualization

0 (Server)

Workflow

0 (Server)

Examples

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..." &amp; vbCrLf,
                  AccessRights.ReadAccess Or AccessRights.WriteAccess, GetEntityReferenceString(teamReference),
                  "Team")
_serviceProxy.Execute(grantAccessRequest1)

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.

See Also

GrantAccessResponse
Microsoft.Crm.Sdk.Messages Namespace
How record-based security can be used to control access to records in Microsoft Dynamics 365
Actions on entity records
Sample: Share records using GrantAccess, ModifyAccess and RevokeAccess messages

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright