Skip to main content

We are new to K2 (just had it installed last week) and are trying to start a process via .NET code. It works when I debug locally but doesnt work when I publish it to our IIS server. I'd like to start a process using the logged in users credentials (domainusername) which works fine when debugging from my dev workstation. K2 server seems to be reading the user as the apppoolidentity account (IIS APPPOOL). I've tried Network Service and Local Service accounts but havent had luck. It seems simple enough. Here is my code:


 


 


 


 


 


 


 


 


 


 


 


 


 


 



 



 



 


SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder();

connectionString.Host =



 



"myservername here";
connectionString.Port = 5252;
connectionString.Integrated =
true;

connectionString.IsPrimaryLogin =



 



true;
Connection connection = new Connection();

 



 



 


//to test which account is being used
string
k2username = String.Empty;
try{
connection.Open(
"myservername here", connectionString.ToString());
k2username = connection.User.DisplayName;
ProcessInstance processInstance = connection.CreateProcessInstance("K2Project1TestProject");
processInstance.Folio = System.
DateTime.Today.ToString();

connection.StartProcessInstance(processInstance,



 



false);}

 



 



 


catch (Exception ex)
{
//some exception handling here
}

 



 



 


finally



{ connection.Close();



 



}


You should not use Network Service or Local service accounts as App Pool. Make sure you use domain accounts. Disable Anonymous Auth on your custom website and enable Integrated Windows Authentication. Make sure web.config of custom website has identityimpersonate=true


thank you Sujeeth. Using the domain account fixed the issue


Reply