Expression Recipes¶
These are worked expressions for the Attribute Flows most deployments need, each ready to adapt to your own attribute names. Every recipe shows the expression, what it produces, and what to watch for; the functions they use are described in full on Expressions, and what happens when an input attribute is missing is set out in Nulls and Missing Inputs.
Account State¶
Active Directory decides whether an account can sign in, and until when, from two attributes: userAccountControl and accountExpires. These recipes set both from what the Metaverse knows about the person.
Enabling and Disabling User Accounts¶
Active Directory uses a userAccountControl attribute to control whether an account is enabled or disabled. The common values are:
| Value | Meaning |
|---|---|
512 |
Normal account, enabled |
514 |
Normal account, disabled |
66048 |
Normal account, enabled, password never expires |
Enable or disable based on employee status:
This reads as: "If the Employee Status is Active, set the value to 512 (enabled), otherwise set it to 514 (disabled)."
Creating accounts enabled on Active Directory
Active Directory refuses to create an enabled account that has no password, so on a Synchronisation Rule that provisions accounts, give the rule an Initial Password as well. JIM then creates the account disabled and enables it once the password is set, and the expression keeps deciding the enabled state from then on. See Enabling new Active Directory accounts.
An account this expression creates disabled (514), such as a pre-hire's, stays disabled when its password is delivered, whatever the Initial Password's Enable the Connected System Object once the password is set says: the expression decides the enabled state. See Accounts your Attribute Flow creates disabled.
Check if an account is currently disabled:
Setting Account Expiration Dates¶
Active Directory stores expiration dates in a special format called FILETIME. JIM provides functions to convert between normal dates and this format automatically.
Set the account expiration from an employee's end date:
Convert an AD expiration date back to a readable date:
Important notes:
- If the date attribute is empty or missing, these functions return nothing (null), which asserts "no value" for the target: for a sole contributor any existing value is removed; see Nulls and Missing Inputs
- AD treats
0and very large numbers as "never expires", soFromFileTime()returns nothing for these values ToFileTime()safely handles empty text, missing values, and invalid dates by returning nothing
Names and Addresses¶
Most Attribute Flows build a value from parts of a name. These recipes join, trim and reshape name attributes into the values target systems expect.
Building Email Addresses¶
For "Jane Smith", this produces: jane.smith@company.com
Building a Display Name with Title¶
Coalesce uses the title if one exists, otherwise uses an empty string, avoiding a "null" appearing in the output.
Generating Initials¶
For "Jane Smith", this produces: JS
Adding a Prefix to Account Names¶
IT department users get a "tech-" prefix; everyone else keeps their account name as-is.
Distinguished Names and OUs¶
A distinguished name (DN) places an object in an LDAP directory. These recipes build one safely, and choose the organisational unit (OU) from an attribute.
Building Distinguished Names (DNs)¶
When constructing LDAP distinguished names, always use EscapeDN() to handle special characters (commas, quotes, etc.) in names:
Without EscapeDN(), a name like "Smith, Jane" would break the DN because of the comma.
Placing Users in Different OUs by Department¶
IIF(Eq(mv["Department"], "IT"),
"OU=IT,OU=Users,DC=domain,DC=local",
IIF(Eq(mv["Department"], "HR"),
"OU=HR,OU=Users,DC=domain,DC=local",
"OU=General,OU=Users,DC=domain,DC=local"))
This nests IIF functions to check multiple conditions: first IT, then HR, with a default of General for everyone else.
Multi-Valued Attributes¶
Some systems keep several values in one delimited field, and some accept only one value per attribute. These recipes convert between the two.
Splitting Delimited Values into a List¶
When a source system stores multiple values in a single field separated by a delimiter (e.g., "COURSE1|COURSE2|COURSE3"), use Split() to break them into separate values.
Example (training courses from a CSV file):
The source CSV has pipe-separated courses in a single column:
Use this expression to create individual values on the Metaverse Object:
This creates three separate values: SOFT101, SOFT201, and SEC101.
Notes:
- Empty entries are automatically removed
- Whitespace is trimmed from each value
- Returns nothing for missing or empty input
- The delimiter can be any text (e.g.,
",","|",";") - Each value is stored in the target attribute's type (
"1|2"into a Number attribute stores 1 and 2); if any value cannot be, nothing flows and the object is reported - Into a single-valued attribute, a list of more than one value flows nothing and the object is reported
Join()puts the values back together in the same order, soJoin(Split(x, "|"), "|")gives backx
Keeping an Account Audit Log¶
To record every account a person has been issued, in every Connected System, and keep the record after the accounts are deleted, create a multi-valued text attribute such as Account Audit Log, set it to the Accumulate contribution mode (see Accumulating values from every contributor), and map it from each Connected System's import Synchronisation Rule with one expression that builds an entry per identifier:
Split("AD|" + cs["objectGUID"] + "|sAMAccountName=" + cs["sAMAccountName"] + ";AD|" + cs["objectGUID"] + "|userPrincipalName=" + cs["userPrincipalName"], ";")
Each entry names the system, the account's unique identifier and one of its names, so the log answers "which accounts has this person had, and what were they called?". A rename adds a new entry beside the old one, and deleting the account removes neither.
Notes:
- Give each Connected System its own prefix (
AD|,Entra|), so entries from different systems never collide - Entries compare exactly; set the Attribute Flow's case normalisation if a source changes the case of a name
Combining a List into a Single Value¶
When exporting to a system that does not support multi-valued attributes, use Join() to combine them into one delimited value.
If the attribute has the values Admin, Users, and Developers, this produces Admin|Developers|Users: an attribute's values are joined in their fixed order (see Multi-Valued Attributes), so the result is the same after every import.
Notes:
- Returns nothing for empty lists
- Empty and missing values are filtered out
- Uses a comma as the default delimiter if none is specified