Study FAQ
Which user does a Dataverse plug-in's Organization service run as?
Also asked as 2
- Which identity does CreateOrganizationService use inside a Dataverse plug-in?
- How does a Dataverse plug-in step's Run in User's Context setting affect its SDK calls?
Answer
Inside a Dataverse plug-in, get IOrganizationServiceFactory from the supplied IServiceProvider and call CreateOrganizationService(context.UserId) to use the effective identity defined by the step registration. The default step setting is Calling User. If a designer sets Run in User's Context to a different user, operations made through that service run with the selected user's Dataverse privileges. Impersonate a user in a Dataverse plug-in
Use context.InitiatingUserId deliberately when the operation should use the user who originally initiated the chain. That identity can differ from the step's effective user. Keep the service and execution context in local variables because Dataverse can reuse plug-in instances. Plug-ins use the SDK Organization service supplied by the platform. Web API calls back into Dataverse from plug-in code are unsupported. Write a Dataverse plug-in
Verify the step with a restricted intended caller. For example, run one permitted related-row read and one intentionally denied write. If the rule can use a registered image, it may need neither call. Treat elevated execution as an explicit trust decision and include it in the registration review. Register a plug-in
Full explanation
AB-400: Dataverse Plug-ins and the Event Execution Pipeline
Study guide · AB-400
Read the full explanation