Introduction

Sometimes, we want to run plugin in System user context to skip the unnecessary security checks.

In this blog, we will see how to Impersonate plugin to run in System User Context.

Prerequisites

  1. Basic knowledge of Dynamics 365 and Plugins

Click here to Learn Plugin’s .

Description

Pass Null to CreateOrganizationService Object instated of “context.UserId” and keep Run in User’s Context to Calling User.

Do not set Run in User’s Context to System (Disabled) from Plugin Registration tool because when the solution is Migrated to another environment, it will not work because of the User Id is different.

So it is recommend to Impersonate user from C# Plugin Code πŸ™‚ πŸ™‚

Cheers !!!! I hope this will save your time πŸ™‚

Reference

https://community.dynamics.com/crm/b/crmbusiness/archive/2015/07/21/crm-2015-understanding-impersonation-in-plugins-and-knowing-when-to-use-it