title: Microsoft Dynamics CRM Async plugin executed by System User
body: <p>I have two plugins registered in the plugin registration tool. Both plugins have "<strong>calling user</strong>" at the "Run at users context" value.</p>
  
  <ol>
  <li>the first plugin has a step registered on post update of Entity X (Async)</li>
  <li>the second plugin has a step registered on the retrievemultiple of products (Sync)</li>
  </ol>
  
  <p>The first plugin retrieves products, so it triggers the second plugin. When I check the <strong>context.UserId</strong> property of the first plugin, I find the userId of the logged in user. But in the second plugin, the property is set to the <strong>SYSTEM users</strong>'s Guid.</p>
  
  <p>I'm using the following code to instatiate the organisationService in both plugins:</p>
  
  <pre><code>    this.OrganizationService = 
  factory.CreateOrganizationService(this.PluginExecutionContext.UserId);
  </code></pre>
  
  <p>Any idea what is going on? Why is the second plugin not executed by the logged in user?</p>
  
  <p>EDIT:</p>
  
  <p>When I look in the system jobs tracing I find the following ID's:</p>
  
  <p>Plugin 1 (Async): </p>
  
  <pre><code>context.Initiating User: Logged in user
  context.User: SYSTEM
  </code></pre>
  
  <p>Plugin 2 (Sync):</p>
  
  <pre><code>context.Initiating User ID: SYSTEM
  context.User ID: SYSTEM
  </code></pre>
  
  <p>It does make sense that the Async service user (SYSTEM) triggers plugin 2, so Context.UserId in Plugin 2 is actually the SYSTEM users Guid. </p>
  
  <p>Actually what I'm trying to do (in pseudo-code) is something like this (in plugin 1):</p>
  
  <pre><code>context.UserId = context.InitiatingUserId
  </code></pre>
  
  <p>But the problem with this is that context.UserId is a read-only property.</p>
  
  <p>Any ideas how to enfore something like this?</p>