Before and After Scripts for IQService

The IQService supports function customization by allowing integrating Before/After scripts implemented in languages like PowerShell and Batch. Scripts can be used to automate any required actions that cannot be automated using current source functions. Scripts called before processing the request are referred to as Native Before Scripts and scripts called after processing the request are referred to as Native After Scripts.

Identity Security Cloud provides most of the provisioning functionality for many systems through its connectors. Some systems provide a better integration interface from the Windows platform compared to other platforms. So connectors for these systems require IQService deployed on a Windows system. The IQService implementation performs the provisioning functions (such as Add User, Connect User to a Group) that are supported by the respective managed system. The IQService functions are called by the Identity Security Cloud source implementation.

In addition to the basic action, some organizations may require supplementary actions performed by each function from the Windows system. The IQService supports customization of the functions by allowing you to integrate Before and After scripts in any language. The following are some features of IQService Before and After scripts:

  • Centralized configurations (in Identity Security Cloud) for setting up Before and After scripts

  • Supports Object Oriented scripting

  • Script refers SailPoint library to get the request and result classes

  • Can be executed with specific context

  • Script can modify requests and results

A script is a group of statements that perform one or more actions and manipulate request and result attributes. Scripts can be used to automate any required actions.

The scripts need to be defined in a rule and then configured for a source in Identity Security Cloud. Based on the rule type (Before or After), the connector sends the scripts to be executed before or after processing the request to IQService.

IQService supports executing Before and After Rules for Create, Modify, and Delete request operations.

Writing a Script

IQService divides scripts in the following categories:

  • Scripts with Object Oriented support

  • Scripts without Object Oriented support

Scripts with Object Oriented Support

Scripting languages with Object Oriented capabilities (for example, PowerShell) are popular because of their simplistic nature and ease of use. These scripts can form objects of any type by referring to any library or assembly implemented in any language and call its methods.

Native scripts implemented in these languages have easier and more powerful access to request and result objects. IQService comes with a class library named Utils.dll which bundles all required classes to access the request and result objects. The inputs provided to the script are in the form of process environment variables. The following table describes the environment variables created by IQService:

Name

Type

Before Script

After Script

Application

System.Collections.Hashtable

Read Only

Read Only

Request

SailPoint.Utils.objects.AccountRequest

Read/Write

Read Only

Result

SailPoint.Utils.objects.ServiceResult

Not Available

Read/Write

The data in the environment variables is in XML. The script creates respective objects using Utils.dll. Once the object is modified, the script converts it to XML by calling the toxml() method of the object and then writes a file at the path passed as the only argument to the script to the XML.

The script returns a non-zero value if an error occurs. It writes the error message in the file at the path passed as the argument to the script. This failure is communicated to Identity Security Cloud as part of a result.

Scripts without Object Oriented Support

Non-Object Oriented scripts do not refer to the class library or support a way of parsing XML. To have easy access to each attribute along with their operation and values, IQService creates process environment variables for each of the application and request attributes. It formats the names as SP_<OPERATION>_<NAME> for requests and SP_APP_<NAME> for applications. For native identity, the environment variable is SP_NativeIdentity. These types of scripts have limited access to results and get only SUCCESS or FAIL in the Result environment variable. So the After scripts implemented using these scripting languages cannot modify any attribute or result. Before scripts can add, modify, or remove any attribute from the request. The script needs to write the newly added or modified attribute to the file at the path passed as an argument to the script in the form SP_<OPERATION>_<NAME>=<VALUE>. To remove the attribute from the request, write /~<ATTRIBUTE_NAME> to the file. The value for the multivalued attribute is delimited by /#/.

The following is a sample batch After script which ensures that the request was processed successfully and creates a home directory at the path specified in the request:

IF %Result% ==SUCCESS md %SP_Set_TS_TerminalServicesHomeDirectory%

Creating a Rule

To add the script to a rule and use it, you need to create a rule. Contact SailPoint Services for assistance on creating rule as per requirement.

Configuring the Rules in Source

Add the nativeRules attribute under the Attributes map with a list of rules that must be configured for a source in Identity Security Cloud using the REST API.

Note
For more information on SailPoint's REST APIs, refer to Best Practices: REST API Authentication and REST API - Update Source (Partial) in the SailPoint Developer Community.