RetrieveSharedPrincipalsAndAccessRequest Class

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

Contains the data that is needed to retrieve all security principals (users or teams) that have access to, and access rights for, 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 RetrieveSharedPrincipalsAndAccessRequest
    Inherits OrganizationRequest
[DataContractAttribute(Namespace="https://schemas.microsoft.com/crm/2011/Contracts")] 
public sealed class RetrieveSharedPrincipalsAndAccessRequest : 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.

var accessRequest = new RetrieveSharedPrincipalsAndAccessRequest
{
    Target = leadReference
};

// The RetrieveSharedPrincipalsAndAccessResponse returns an entity reference
// that has a LogicalName of "user" when returning access information for a
// "team."
var accessResponse = (RetrieveSharedPrincipalsAndAccessResponse)
    _serviceProxy.Execute(accessRequest);
Console.WriteLine("The following have the specified granted access to the lead.");
foreach (var principalAccess in accessResponse.PrincipalAccesses)
{
    Console.WriteLine("\t{0}:\r\n\t\t{1}",
        GetEntityReferenceString(principalAccess.Principal),
        principalAccess.AccessMask);
}
Console.WriteLine();

Dim accessRequest = New RetrieveSharedPrincipalsAndAccessRequest With
                    {
                        .Target = leadReference
                    }

' The RetrieveSharedPrincipalsAndAccessResponse returns an entity reference
' that has a LogicalName of "user" when returning access information for a
' "team."
Dim accessResponse = CType(_serviceProxy.Execute(accessRequest), 
    RetrieveSharedPrincipalsAndAccessResponse)
Console.WriteLine("The following have the specified granted access to the lead.")
For Each principalAccess In accessResponse.PrincipalAccesses
    Console.WriteLine(vbTab & "{0}:" & vbCrLf & vbTab & vbTab & "{1}",
                      GetEntityReferenceString(principalAccess.Principal),
                      principalAccess.AccessMask)
Next principalAccess
Console.WriteLine()

Remarks

Message Availability

This message works regardless whether the caller is connected to the server or offline. However, a few entities of this message class are exceptions to that availability. To determine which entities have a more restricted availability, see Supported Entities later in this topic.

Usage

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

Privileges and Access Rights

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

Supported Entities

The following table shows the default entities that support this message. For the listed entities of this message, the Availability column shows Server if the caller must be connected to the server and shows Both if the caller can be either connected to, or disconnected from, the server.

Entity Availability

account

Both

annotation

Both

appointment

Both

campaign

Both

campaignactivity

Both

campaignresponse

Both

connection

Both

contact

Both

contract

Both

customeropportunityrole

Both

customerrelationship

Both

duplicaterule

Server

email

Both

emailserverprofile

Server

fax

Both

goal

Both

goalrollupquery

Both

import

Both

importfile

Both

importmap

Both

incident

Both

incidentresolution

Both

invoice

Both

lead

Both

letter

Both

list

Both

mailbox

Server

mailmergetemplate

Both

opportunity

Both

opportunityclose

Both

orderclose

Both

phonecall

Both

processsession

Both

queue

Both

quote

Both

quoteclose

Both

recurringappointmentmaster

Both

report

Both

salesorder

Both

serviceappointment

Both

sharepointdocumentlocation

Both

sharepointsite

Both

task

Both

template

Both

userform

Both

userquery

Both

userqueryvisualization

Both

workflow

Server

Inheritance Hierarchy

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

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

RetrieveSharedPrincipalsAndAccessRequest Members
Microsoft.Crm.Sdk.Messages Namespace
Entity Ownership
RetrieveSharedPrincipalsAndAccessResponse

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.