Skip to main content


 

Symptoms


I'm creating a process programmatically (ProcessInstance processInstance = connection.CreateProcessInstance(ProcName)). I need to set the originator of the process to be a specific user (I have the user ID), rather than the executing user (which is a service account). How can I achieve this?
 

Diagnoses


You will likely need to give this service account 'Impersonate' rights in K2 'Server Rights' and use connection impersonate to start the process instance:

https://www.k2.com/onlinehelp/k2blackpearl/devref/current/default.htm_start_instance_and_get_data_fields.html
*toward the bottom of this documentation
 

Resolution

When calling Connection.ImpersonateUser(), the following error occurred:

Error Connecting to K2: Integrated=TrueIsPrimaryLogin=TrueAuthenticate=TrueEncryptedPassword=FalseCachePassword=TrueHost=K2Port=5252SecurityLabelName=K2
Error Message: Object reference not set to an instance of an object.
at SourceCode.Workflow.Client.User.LoadProperties()
at SourceCode.Workflow.Client.User.get_Name()
at SourceCode.Workflow.Client.Connection.ImpersonateUser(String UserName)
at Something.SomethingElse.CreateK2Instance1(String CM)

Giving the Service Account running this application 'Impersonate' rights via iK2 Workspace > Management > Management Console > tServer:Port] > Workflow Server > Server Rights] resolved the issue.




 
Be the first to reply!

Reply