I am using Workflow Foundation WF4 and would like to impersonate or "run as" users when running a WorkflowApplication instance.
To access the user I would like to use Thread.CurrentPrincipal
I am trying to find a solution whereby I can impersonate or configure a user for the scope/lifetime of the WorkflowApplicaton instance. The workflow should run under the security context of the supplied claims principal for all activities executed within it.
The claims principal used on one instance should not affect any other threads or any other WorkflowApplication instances within the process - it should be isolated.
I have been investigating SynchronizationContext. WorkflowApplication allows you to use any implementation of SynchronizationContext. I am not confident about the implications of setting Thread.CurrentPrincipal in a custom implementation. Will it flow/propagate through the activity hierarchy? Can principals be locked to the threads running the workflow?
Anybody have any ideas about confidently implementing something with these requirements?