Creating Code-Based Sets

Code-based Sets are queries that can result in both collections of people or collections of other resource types protected by EmpowerID. Each Code-based Set requires a Set Runtime, which is a custom implementation of the EmpowerID API that allows C# code be used to return a collection of EmpowerID object types. This topic will walk you through the process.

To create a Code-based Set

  1. Log in to Workflow Studio.
  2. From Solution Explorer (located to the left of the Workflow Studio IDE), select the Workspace node. You should see the Workspace tree, which presents a tree view of the packages and package items in your personal Workspace.
  3. From the Workspace tree, right-click the Package node of your choice and select Add New Item > EmpowerID Set Runtime from the Workspace context menu.
  4. In the Add New Set Runtime window that appears, enter "Helpdesk Technicians" into the Name text field and then click OK.
  5. You should see Workflow Studio do the following:
    • Update Source Control for your Workspace, creating a Set Runtime Source Control Folder and adding the Helpdesk Technicians Set Runtime to the folder as a package item in the package you selected above.
    • Open the C# Editor stubbed for the new Set Runtime in the Document Space. All Set Runtime objects you create in Workflow Studio use the GetResults() method of the ISetRuntime interface of the TheDotNetFactory.Framework.People.Components namespace. The C# Editor is where you add your custom code for the Set Runtime.
    • Add the HelpdeskTechnicians.cs class file to the Classes folder in the Code Tree of the Toolbox on the right of the Workflow Studio IDE.

    The following image shows the new Helpdesk Technicians Set Runtime in Workflow Studio. When you create a new Set Runtime object, Workflow Studio adds the Set Runtime as a package item to the package in which you created it, adds a corresponding CS file to the Code Tree and opens the C# Editor to allow you to add your custom code.

  6. In the C# Editor, delete "throw new NotImplementedException();" from the body of the GetResults() method and replace it with code to do the following:
    1. Create a new instance of the TheDotNetFactory.Framework.People.Components.Person class, using the Find() method to find EmpowerID Person objects with a title of "Helpdesk Technician"
    2. Create a new instance of the TheDotNetFactory.Framework.People.Components.SetCompilation class
    3. Loop through the new instance of the Person class, adding each person returned by the Find() method to the new instance of the SetCompilation class, writing the PersonGUID DisplayName of the SetCommpilation class to the FriendlyName property for each person in the collection.
    4. Return the results of the collection.

    The following shows what the GetResults() method looks like with the above code entered into the method's body:

    int totalCount = -1;
        E.TList<Person> people = Person.Find
             ("Title = Helpdesk Technician", 0, int.MaxValue, out totalCount);
        E.TList<SetCompilation> results = new E.TList<SetCompilation>();
        foreach (Person p in people)
             results.Add(new SetCompilation(){SystemIdentifier = p.PersonGUID.ToString(),DisplayName
            = p.FriendlyName});
            return results;
    If you use LINQ to return results, the SELECT statement cannot contain any characters that XML does not escape (<, >, ", ', &).
  7. Compile the Set Runtime by clicking the Compile button in the toolbar located just above the C# Editor. Compiling the Set Runtime allows you to verify that your code contains no syntax errors.

  8. You should see the Operations Log open with a message stating the HelpdeskTechnicians.dll compiled successfully. If the compile was unsuccessful, you will see the details of problem in the Error Message text field at the bottom of the log. Click the Close button to close the Operations Log.
  9. Click the Compile and Publish button in the toolbar located just above the C# Editor to publish the Set Runtime to the Enterprise Workflow Server(s). Publishing the Set Runtime to the Workflow Server(s) makes it available to EmpowerID as a manageable object that can be used in your delegation scenarios.

  10. In the Set Runtime Publishing wizard that appears, click the Next button.
  11. Select the Enterprise Workflow Server to which you want to publish the Set Runtime and click Next.
  12. Click Next and follow the wizard to completion of the publishing process.
  13. In the Set dialog that appears, click Yes. This will allow us to create a code-based Set to associate with the Set Runtime.
  14. In the Add Set dialog that appears, do the following:
    1. Enter HelpdeskTechniciansSet in the Name field.
    2. Enter Helpdesk Technicians in the Friendly Name and Description fields.
    3. Select EmpowerID Person from the Object Type drop-down.
    4. Select both Is Enabled and Compile Now.
    5. Enter the desired parameters for the compilation schedule and then click OK.

    The Add Set dialog should look similar to the below image.

    To allow the Set to run, you must enable the Set Compiler Job form the EmpowerID Servers and Roles node in Configuration Manager.
  15. When prompted to restart one or more services, click Yes.
  16. In the Active Services window that appears, select the EmpowerID services and then click Restart.
Code-based Sets must be paired with a SetGroup in order to be used in any RBAC scenarios.