Thursday, October 20, 2011

Impersonation in CRM2011

Impersonate in Plugins:

ICrmService service = context.CreateCrmService(context.InitiatingUserId);
Instead of context.InitiatingUserId use the user guid of the user.

ICrmService service = context.CreateCrmService(userId);

To Impersonate in WebPages:
Create crmservice and assign callerid property to the user to be impersonated.