title | description | keywords | ms.date | ms.custom | ms.topic | applies_to | ms.assetid | author | ms.author | ms.reviewer | ms.suite | ms.tgt_pltfrm | caps.latest.revision | topic-status | search.audienceType | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Sample: Associate a Security Role to a User (Developer Guide for Dynamics 365 Customer Engagement) | MicrosoftDocs |
The sample shows how to associate a role with a user by using the IOrganizationService.EntityReferenceCollection) method. |
10/31/2017 |
sample |
|
c962101c-65f0-4e49-8c23-99c2a9e7dcbf |
JimDaly |
nabuthuk |
pehecke |
17 |
Drafting |
|
This sample code is for [!INCLUDEpn_dynamics_crm_online].
[!INCLUDEsdk-prerequisite]
[!INCLUDEsdk_SeeConnectionHelper]
This sample shows how to associate a role with a user by using the xref:Microsoft.Xrm.Sdk.IOrganizationService.xref:Microsoft.Xrm.Sdk.IOrganizationService.Associate* method. A snippet showing just the key portions 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 associating a role with a user will work for all environments.
[!INCLUDEcc_sdk_onpremises_note]
[!code-csharpUsersAndRoles#AddRoleToUser1]
[!code-csharpUsersAndRoles#AddRoleToUser]
Privilege and Role Entities
Sample: Determine Whether a User has a Role
User and Team Entities
xref:Microsoft.Xrm.Sdk.IOrganizationService
[!INCLUDEfooter-include]