Creating and using Connection Strings
When creating a programmatic connection to K2 (typically when using the SourceCode.Workflow.Client,SourceCode.Workflow.Management or SourceCode.SmartObjects.Client APIs) there are a number of connection string formats you can use. The recommended way to create a K2 connection string is using the SCConnectionStringBuilderclass, located in the SourceCode.Hosting.Client.BaseAPI assembly.
The table below explains some of the common properties available when building a connection string:
Property | Type | Description |
---|---|---|
Host | String | The server that is being connected to. If using a K2 server farm, the farm name should be used. You can also specify an IP address.
Code that is running on the same physical machine as the K2 host service should use "localhost" as the Host to keep communication internal on the physical machine, unless you specifically want to "step out" to the K2 server farm name. |
Port | Int | The port to use for the connection. Workflow.Client connections are made over port 5252 by default. All other connections (such as Workflow.Management or SmartObjects.Client) should use port 5555 by default. It is possible to change these ports when installing K2, so your port number may be different. When you wish to establish a connection using these classes over a firewall, the firewall must be configured to allow RPC communication over ports 5252 and 5555. |
Authenticate | bool | If true: authenticate the user's credentials against the security provider. Usually set to true. |
Integrated | bool |
If true: use the logged on user. If Integrated is set to true in the connection string, the domain may need to be specified as part of the user name. e.g. DENALLIX\\Anthony instead of just the user name. e.g. Anthony |
IsPrimaryLogin | bool | If true: re-authenticate user. If false: use cached security credentials if available. |
SecurityLabelName | String | The Label of the Security Provider to use to authenticate the user. "K2" is the standard Windows Authentication provider, "K2SQL" is the standard K2 SQL User Manager. For other security providers, you should provide the appropriate security label name., |
WindowsDomain | String | When using windows authentication, provide the name of the domain that the specified username is associated with. |
UserID | String | The username/userID to be used when opening the connection. |
Password | String | The password for the specified username to be used when opening the connection. |
See the topic Connection String Samples for some code samples of typical connection strings