I am trying to terminate a running workflow instance using the following piece of code from C# project.
WorkflowManagementServer server = new WorkflowManagementServer();
//Define connection string
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder myConnStr = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
myConnStr.Host = "K2 Application Server Name"; //replace
myConnStr.Authenticate = true;
myConnStr.Integrated = true;
myConnStr.IsPrimaryLogin = true;
myConnStr.EncryptedPassword = false;
myConnStr.Port = 5555;
myConnStr.UserID = "admin user id"; //replace
myConnStr.WindowsDomain = "domain"; //replace
myConnStr.Password = "password"; //replace
//myConnStr.SecurityLabelName = string.Empty;
myConnStr.AuthData = string.Empty;
//Open connection
server.Open(myConnStr.ToString());
//server.StopProcessInstances(277);
server.DeleteProcessInstances(449,true); //you have to know process instance ID - 2nd parameter is deleteLogEntries}
Each time, I run this, I am getting the blow given error
“User K2:xxxx does not have administrator permissions"
I tried using the service account using which this was installed, and also using the account under which K2 Black Pearl Service is running. Still the same error.
What am I missing here?
Thanks in Advance.