Symptoms
Customer develops a Web Application using OWIN forms authentication that will integrate with K2. The application will throw the following error when try to execute connection.open:
"Claims token xml is empty" error.
Diagnoses
The reason that the open connection is failing is because the user in this case is a Claims user which K2 does not aware of the Claims Provider.
Resolution
Using the following connection string, the customer was able to connect to K2 successfully:
public bool StartNewProcess(string processName, string userName, IEnumerable dataFields)
{
ProcessInstance instance
using (_impersonationContextFactory.CreateImpersonationContextForK2())
using (var k2Conn = new Connection())
{
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder()
builder.Authenticate = true
builder.Host = _configurationProvider.K2Server
builder.Port = 5252 //use port 5252 for SourceCode.Workflow.Client connections
builder.Integrated = false
builder.IsPrimaryLogin = true
builder.SecurityLabelName = "K2"
builder.UserID = "DOMAINUSER"
builder.Password = "xxxxxx"
builder.WindowsDomain = "DOMAIN"
k2Conn.Open(_configurationProvider.K2Server, builder.ConnectionString)
k2Conn.ImpersonateUser(userName)
instance = k2Conn.CreateProcessInstance(processName)
if (dataFields != null andand dataFields.Any())
{
dataFields.ToList().ForEach(field => ApplyDataField(field, instance))
}
k2Conn.StartProcessInstance(instance)
}
return true
}