K2 BLACKPEARL PRODUCT DOCUMENTATION: USER GUIDE
Run As Verification

Verification that Run As is working

Verifying that Run As is working as expected and is retrieving the specified credentials correctly can be done easily be creating a simple process with one server event and a few lines of code. All the example will illustrate is the following for a design time scenario:

To create a simple process with a server event, do the following:

Launch K2 designer for Visual Studio

Start a new K2 project, with the name K2 Run As Test

Add one server event to the design canvas, and connect the Start Activity to the Server Activity using a line rule

Expected Result:

Expected Result

Change the server event credentials

Locate the Service Account Event Template

Run the template and amend the credentials by clicking on the Change button

Existing K2 Server Service Account Credentials

Specified Credentials, which is also a service account but not the K2 Server Service Account:

New, specified credentials

Add the server event code

The following lines of code must be added to the two server events. The code will perform the simple task of extracting the  credentials used to run the Server Event.

Server Code Example
Copy Code
Console.WriteLine("-------------------------------------------");
Console.WriteLine(WindowsIdentity.GetCurrent().Name);
Console.WriteLine("-------------------------------------------");

Console Line Results

Shown in the images below, are the results from running a published version of the process in console mode. To achieve a similar result, the Developer would need to do the following:

  1. Publish the process
  2. Restart the K2 Server in console mode
  3. Instantiate an instance of the process and monitor the result via the console

Console Mode 

 

 


K2 blackpearl Help 4.6.10 (4.12060.1690.0)