RetrievePrincipalAccess Message

banner art

Retrieves the access that the security principal (user) has for the specified entity.

The relevant classes are specified in the following table.

Type Class
Request RetrievePrincipalAccessRequest
Response RetrievePrincipalAccessResponse
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
campaignactivity TargetOwnedCampaignActivity
campaignresponse TargetOwnedCampaignResponse
contact TargetOwnedContact
contract TargetOwnedContract
customeropportunityrole TargetOwnedCustomerOpportunityRole
customerrelationship TargetOwnedCustomerRelationship
email TargetOwnedEmail
fax TargetOwnedFax
incident TargetOwnedIncident
incidentresolution TargetOwnedIncidentResolution
invoice TargetOwnedInvoice
lead TargetOwnedLead
letter TargetOwnedLetter
list TargetOwnedList
opportunity TargetOwnedOpportunity
opportunityclose TargetOwnedOpportunityClose
orderclose TargetOwnedOrderClose
phonecall TargetOwnedPhoneCall
quote TargetOwnedQuote
quoteclose TargetOwnedQuoteClose
salesorder TargetOwnedSalesOrder
serviceappointment TargetOwnedServiceAppointment
template TargetOwnedTemplate
userquery TargetOwnedUserQuery
User owned custom business entities TargetOwnedX where X is the name of the custom entity
Dynamic entity TargetOwnedDynamic

Remarks

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 RetrievePrincipalAccess Privileges.

Example

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

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

// Create the SecurityPrincipal object.
// This class references the user whose access is being checked.
SecurityPrincipal principal = new SecurityPrincipal();

// Set the properties of the SecurityPrincipal object.
// Type is the typecode of the principalid.
principal.Type = SecurityPrincipalType.User;
// PrincipalId is the GUID of the user whose access is being checked.
principal.PrincipalId = new Guid("F111F0B1-70CE-44B4-8BF2-2E6C7EADA111");

// Create the target for the request.
TargetOwnedAccount owner = new TargetOwnedAccount();

// EntityId is the GUID of the account to which access is being checked.
owner.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
RetrievePrincipalAccessRequest access = new RetrievePrincipalAccessRequest();

// Set the properties of the request object.
access.Principal = principal;
access.Target = owner;

// Execute the request.
RetrievePrincipalAccessResponse accessResponse = (RetrievePrincipalAccessResponse)service.Execute(access);

[Visual Basic .NET]
' Set up the CRM Service.
Dim service As New CrmService()
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the SecurityPrincipal object.
' Reference the user whose access is being checked.
Dim principal As New SecurityPrincipal()

'Set the properties of the SecurityPrincipal object.
'Type is the typecode of the principal ID.
principal.Type = SecurityPrincipalType.User
' PrincipalId is the GUID of the user whose access is being checked.
principal.PrincipalId = new Guid("F111F0B1-70CE-44B4-8BF2-2E6C7EADA111");

' Create the target for the request.
Dim owner As New TargetOwnedAccount()

' EntityId is the GUID of the account to which access is being checked.
owner.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

' Create the request object.
Dim access As New RetrievePrincipalAccessRequest()

' Set the properties of the request object.
access.Principal = principal
access.Target = owner

' Execute the request.
Dim accessResponse As RetrievePrincipalAccessResponse = CType(service.Execute(access), RetrievePrincipalAccessResponse)

Related Topics

CrmService Messages

© 2007 Microsoft Corporation. All rights reserved.