Substitute Function
Substitute Function

Substitute Function

This function is used to extract the part of the AD attribute value and use it as key for a lookup table provided in the function to get the corresponding value from the lookup table.
Params JSON Parameters for Substitute Function
Attribute Name
Data Type
Description
value
String
Value field on which regex pattern is applied. This could be the combinations of one or many AD attributes or constants strings.


For example, if the AD attribute value of
extensionattribute7 is 10245-0843-SRE-Apparel,
${extensionattribute7} is evaluated as
10245-0843-SRE-Apparel

If the value requires backslash (\) or double quotes, then these characters should be escaped with another backslash (\).For example, value pttpro\${givenname} should be given as pttpro\\${givenname}.
pattern
String
regex pattern to be applied on the value.
If the pattern requires backslash (\) or double quotes, then these characters should be escaped with another backslash (\).


For example; pattern ^\d{4} should be given as ^\\d{4}.

index (optional)
Integer
If the pattern matches with multiple values, it returns the pattern value at the given index.


Default Value: 0

group (optional)
Integer
If the regex uses grouping, it returns the group value.


Default value:0

map
Map of Name and Value
List of name and value pair for replacing the key name with value.


For example;

{ "1023": "admin", "1024": "sme", "1025":"associate", "1026":"standard" }
Example 1
Map the user attribute department to the AD attribute extensionattribute7. The extensionattribute7 value in AD is 10245-0843-SRE-Apparel.
Function of mapping the department attribute
{ "function":"substitute", "params":{ "value":"${extensionattribute7}", "pattern":"^\\d{4}", "index": 0, "group": 0, "map": { "1023": "admin", "1024": "associate", "1025":"sme", "1026":"standard" } } }
This should extract first 4 digits from extensionattribute7 AD attribute value and lookup for the map attribute to get the value pair for this name and map to the user attribute.department.
In the above example first 4 digit extracted to 1024.
Look up for 1024 in the map attribute which is associated with user attribute department and user attribute department sets with associated value.
Example 2
Map the user attribute department to the AD attribute extensionattribute7. Theextensionattribute7 value in AD is jobid=1024.
Function of mapping the department attribute
{ "function":"substitute", "params":{ "value":"${extensionattribute7}", "pattern":"(jobid=)(\\d{4})", "index": 0, "group": 2, "map": { "1023": "admin", "1024": "associate", "1025":"sme", "1026":"standard" } } }
In this example, pattern is used to divide the value in 2 groups. This should return the 4 digit value from the second group. (group 0 always returns the entire source string). Once the digits are extracted, look up for the map attribute to get the value pair for this name and map to user attribute department .
In the above example first 4 digit extracted to 1024.
Look up for the 1024 in the map attribute which is associated with the user attribute department and user attribute department sets with the associated value.
  • if the key (1024 in this example) is not found in the map, it sets the null value to the department user attribute.
  • If user attribute is mandatory type, then importing of user fails.