Sonntag, 1. Juli 2012 01:19
When a plugin executes, it has a context with 2 members that are of type guid:
My question is I want the Guid of the human end user that participates in firing the plugin with his/her actions. In other words if John Doe is the end user and the plugin is registered with Run as 'windows account', which one is John Doe's Guid?
The plugin context has 2 kinds of GUIDs;
Gets the global unique identifier of the system user for whom the plug-in invokes Web service methods on behalf of. (inherited from IExecutionContext)
Gets the global unique identifier of the system user account under which the current pipeline is executing. (inherited from IExecutionContext)
Sonntag, 1. Juli 2012 07:40
userid would return the logged in users unique identifier.
Register the plugin to run under the context of logged in user and not a specific account.
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"
Sonntag, 1. Juli 2012 13:14
UserID is the user running the plugin (under whose context the plugin is running) where as
InitiatingUserId is the use who has initiated the change from the CRM UI.
To explain more I am attaching the plugin registration tool screen shot. Hope it helps
Sonntag, 1. Juli 2012 18:34
So in your snapshot, if Tushar is the end user and the plugin is registered with Devashish, the context user id is Devashish.
In my scenario, Tushar is the end user, my plugin is registered wtih CRMAccount. I need the business unit and roles of Tushar not CRM account. So the initiatingUserId is the one?
We register the step( in your snapshot) with a Windows service account such as CRMAccount. It is not a human user account such as John Doe of Devashish Baipai. We cannot register the sep with John Doe's account because John Doe is a valid CRM user but with very little privileges. The plugin needs to access other resources that John Doe cannot thus the usage of the Windows service account.
Sonntag, 1. Juli 2012 18:37
We register the plugin to run with a Windows service account ( for example CRMAccount) because it is granted more privileges to access resources etc...
So if we don't register the plugin to run under the context of logged in user, the userid will not necessarily be that of the logged in user?
Sonntag, 1. Juli 2012 19:27
Correct in your case you should look at initiatingUserId.
Thanks for explaining the reason why you are running it under a power use account.
Sonntag, 1. Juli 2012 19:32
Yes you are correct userID is for the user who is running the plugin. In your case it will be a power user not John Deo. Had you selected 'Calling user' the plugin would have executed under the user who has operated on the UI.
-DevashishIf you find this post helpful please vote for helpful or mark it as answered.