Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 2.35 KB

File metadata and controls

51 lines (38 loc) · 2.35 KB
title description ms.custom ms.date ms.reviewer ms.suite ms.tgt_pltfrm ms.topic applies_to ms.assetid caps.latest.revision author ms.author search.audienceType
Sample: Remove a role for a user (Developer Guide for Dynamics 365 Customer Engagement) | MicrosoftDocs
The sample shows how to disassociate a role from a user by using the IOrganizationService.EntityReferenceCollection) method.
10/31/2017
pehecke
sample
Dynamics 365 Customer Engagement (on-premises)
6f25132e-30d2-4a20-9395-3e42aafdd959
16
JimDaly
jdaly
developer

Sample: Remove a role for a user

This sample code is for [!INCLUDEpn_dynamics_crm_online]. Download the complete sample from Sample: Work with Users and Roles.

Prerequisites

[!INCLUDEsdk-prerequisite]

Requirements

[!INCLUDEsdk_SeeConnectionHelper]

Demonstrates

This sample shows how to disassociate a role from a user by using the xref:Microsoft.Xrm.Sdk.IOrganizationService.xref:Microsoft.Xrm.Sdk.IOrganizationService.Disassociate* method. A snippet showing just the key sections of the sample is shown first, followed by the complete sample code. Note that this sample can only be run in an on-premises environment because it creates a user. However, the section of the sample that demonstrates disassociating a role from a user will work for all environments.

[!INCLUDEcc_sdk_onpremises_note]

Example

[!code-csharpUsersAndRoles#RemoveRoleFromUser1]

Complete sample code

[!code-csharpUsersAndRoles#RemoveRoleFromUser]

See also

Privilege and Role Entities
Sample: Retrieve the Roles for an Organization
User and Team Entities
xref:Microsoft.Xrm.Sdk.IOrganizationService

[!INCLUDEfooter-include]