Changing credentials during runtime

This recipe will show you how to use the Change credential element to change the user who is currently executing the workflow.

Getting ready

We need to create a new workflow.

For this recipe, you will need to have more than one AD/LDAP group configured to have access to Orchestrator. Remember that you can use the Orchestrator internal LDAP to test this. To facilitate this, please follow the User management recipe in Chapter 7, Interacting with Orchestrator.

How to do it...

  1. Create a new workflow with the following variable:

    Name

    Type

    Section

    Use

    newCredential

    Credential

    IN

    The user name and password of the new user

  2. Drag a Change credential element onto the schema.
  3. Bind the newCredential in-parameter to the Change credential element.
  4. Now, drag one System log element before and one after the Change credential element.
  5. Edit the System log elements. Remove the text input and change the log to workflow.runningUserName. This will log the username that is currently running the workflow.
  6. Save and run the workflow.
  7. When asked, enter new credentials (for example, vcouser). When the workflow is finished, have a look at the logs. You should see that the name of the user who executed the workflow has changed (see the following screenshot):

    How to do it...

How it works...

The usage is simple; you define the user who executes the workflow from the Change Credential element onward.

A typical usage is that you have a workflow started by a user who has no rights to create a VM on vCenter. So, what you need to do is switch credentials before the VM is created and switch them back for the rest of the workflow. The best practice (please note that this is only true when you use the vCenter plugin with a session for each user) for this is to put the elevated credentials that are used into a configuration (see the recipe Working with configurations in Chapter 8, Better Workflows and Optimized Working).

See also

The example workflow 05.07 Change Credentials.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset