5
votes

I'm writing MS Dynamics CRM 2011 plugin who is performing manipulations with data on behalf of the system user: changing statuses in required manner, filling administrative information, etc.

I'm using following code to get OrganizationService running on behalf of the SYSTEM:

IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(null);

And on development environment everything is running smoothly, but when I deploying assembly on staging environment, for some reason this code is not working anymore. System have chosen one user, let's call him John Doe and runs actions on behalf of him.

I cannot get why this might happen: both environment are more or less the same, the only difference is the IFD used on staging.

Is it possible to disable user SYSTEM somewhere in the MS CRM? If yes, where I can find this setting? What else I should check to resolve the issue?

1
The SYSTEM and INTEGRATION users are always disabled by CRM, but the impersonation should still work. If you display an unfiltered view of your users, are SYSTEM and INTEGRATION both displayed?Andy Meyers

1 Answers

3
votes

The way in which you create an IOrganizationService object is correct

The parameter 'null' on the CreateOrganizationService function indicates that a service will be created for the SYSTEM account. Retrieves and created will be done by the SYSTEM account. No further impersonation is needed.

For more information see MSDN.

Is the plugin is registered in the same way in both environments? In the PluginRegistrationTool is it possible to select an different user under which the plugin is running. What do you selected there?

You cannot disable the system user, the user is default disabled. System processes will use the account.