K2 blackpearl Connections Strings
When creating a programmatic connection to K2 (typically via either the SourceCode.Workflow.Client or SourceCode.Workflow.Management APIs) there are a number of connection options that can be used. I wanted to highlight a couple of common scenarios here.
First of all, the easiest way to create a K2 connection string is via the SCConnectionStringBuilder (SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder). I will show 3 common connection string builder scenarios.
Some basic assumptions before we begin:
- These examples will assume the default blackpearl security lables are in place, where the 'K2' security label equates to Active Directory and the 'K2SQL' security label works with the SQL User Manager.
- Connection strings to the workflow server are shown (as denoted by the port = 5252) for use when making a Workflow.Client connection. If you wish to connect to Workflow.Management or SmartObjects.Client, then you will use port 5555.
1. Make a connection under the currently Windows Identity that is running this code:
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = true;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2";
2. Force the connection under a specific AD Identity
(Note: a Domain Name, User ID and Password must be provided)
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = true;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2";
builder.WindowsDomain = "k2demo";
builder.UserID = "carolm";
builder.Password = "k2pass";
3. Make a connection that authenticates against the K2 SQL User Manager
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = false;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2SQL";
builder.UserID = "jdoe";
builder.Password = "k2pass";
Once you have the connection string builder populated you can use it in the various API connections.
For example, some common ones:
1. SourceCode.Workflow.Client (for workflow interaction)
NOTE: the port used here would be 5252
SourceCode.Workflow.Client.Connection oConn = new SourceCode.Workflow.Client.Connection();
oConn.Open("localhost", builder.ConnectionString);
2. SourceCode.Workflow.Management (for administrative functionality)
NOTE: the port used here would be 5555
SourceCode.Workflow.Management.WorkflowManagementServer oConn = new SourceCode.Workflow.Management.WorkflowManagementServer();
oConn.CreateConnection();
oConn.Connection.Open(builder.ConnectionString);
3. SourceCode.SmartObjects.Client (for SmartObject interaction)
NOTE: the port used here would be 5555
SourceCode.SmartObjects.Client.SmartObjectClientServer oConn = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
oConn.CreateConnection();
oConn.Connection.Open(builder.ConnectionString);
When creating a programmatic connection to K2 (typically via either the SourceCode.Workflow.Client or SourceCode.Workflow.Management APIs) there are a number of connection options that can be used. I wanted to highlight a couple of common scenarios here.
First of all, the easiest way to create a K2 connection string is via the SCConnectionStringBuilder (SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder). I will show 3 common connection string builder scenarios.
Some basic assumptions before we begin:
- These examples will assume the default blackpearl security lables are in place, where the 'K2' security label equates to Active Directory and the 'K2SQL' security label works with the SQL User Manager.
- Connection strings to the workflow server are shown (as denoted by the port = 5252) for use when making a Workflow.Client connection. If you wish to connect to Workflow.Management or SmartObjects.Client, then you will use port 5555.
1. Make a connection under the currently Windows Identity that is running this code:
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = true;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2";
2. Force the connection under a specific AD Identity
(Note: a Domain Name, User ID and Password must be provided)
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = true;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2";
builder.WindowsDomain = "k2demo";
builder.UserID = "carolm";
builder.Password = "k2pass";
3. Make a connection that authenticates against the K2 SQL User Manager
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder =
new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
builder.Authenticate = true;
builder.Host = "localhost";
builder.Port = 5252;
builder.Integrated = false;
builder.IsPrimaryLogin = true;
builder.SecurityLabelName = "K2SQL";
builder.UserID = "jdoe";
builder.Password = "k2pass";
Once you have the connection string builder populated you can use it in the various API connections.
For example, some common ones:
1. SourceCode.Workflow.Client (for workflow interaction)
NOTE: the port used here would be 5252
SourceCode.Workflow.Client.Connection oConn = new SourceCode.Workflow.Client.Connection();
oConn.Open("localhost", builder.ConnectionString);
2. SourceCode.Workflow.Management (for administrative functionality)
NOTE: the port used here would be 5555
SourceCode.Workflow.Management.WorkflowManagementServer oConn = new SourceCode.Workflow.Management.WorkflowManagementServer();
oConn.CreateConnection();
oConn.Connection.Open(builder.ConnectionString);
3. SourceCode.SmartObjects.Client (for SmartObject interaction)
NOTE: the port used here would be 5555
SourceCode.SmartObjects.Client.SmartObjectClientServer oConn = new SourceCode.SmartObjects.Client.SmartObjectClientServer();
oConn.CreateConnection();
oConn.Connection.Open(builder.ConnectionString);