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
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