PowerObjects Blog 

for Microsoft Business Applications


How to Impersonate in Microsoft Dynamics CRM


How to Impersonate in Microsoft Dynamics CRM

When utilizing CRM Portals for Microsoft Dynamics CRM, there are many things you will consider as you begin to implement. How you connect to Dynamics CRM is one of those important decisions.

In most typical portal implementations, a service account is used to connect to CRM.  This is the account that reads and writes all needed data to CRM.  This also means that when any record is created or updated through the portal, the records gets stamped with this service account user.  This is typically ok, but there are some cases where we do not want the record being created with the service account user name but with a specific CRM user.

For example, one scenario may be where we are creating opportunities via a portal.  In such a case, perhaps in addition to being owned by a sales person, we want the created by to also reflect this sales person.

This can be achieved by using impersonation.  There are the two steps needed to impersonate in Microsoft Dynamics CRM:

  • The user (impersonator) must have the ActOnBehalfOf privilege or be a member of the PrivUserGroup group in Active Directory
  • Setting the CallerId property of the organization Web service proxy. Please find below a sample code that shows how to set the caller id of the organization service proxy

Impersonate in Microsoft Dynamics Crm

Note: the SystemUser is custom class we created for accessing system user entity fields in crm and CrmService is another custom class we created for creating an instance of organization service proxy

Happy CRM'ing!

By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends