Hello,
Yes, sure. You can do this with the help of a PowerShell script. For example, the following script trims leading and trailing whitespace from the First Name and Last Name properties:
$props = @("givenName", "sn") # TODO: Modify me
foreach ($prop in $props)
{
if ($Context.IsPropertyModified($prop))
{
try
{
$value = ($Context.GetModifiedPropertyValue($prop)).Trim()
}
catch
{
continue
}
$Context.SetModifiedPropertyValue($prop, $value)
$Context.LogMessage($prop + ": " + $value, "Information")
}
}
In the script, $props specifies the properties, values of which need to be trimmed. If necessary add other properties you need.
To use the script with Adaxes, you need to create a Business Rule triggered before an operation is complete:
- before creating a user: to trim properties on user creation,
- before updating a user: to trim properties when a user account is modified.
To launch the script in a Business Rule, you need to use the Run a program or PowerShell script action.
To create such Business Rules:
-
Create a new Business Rule.
-
On the 2nd step of the Create Business Rule wizard, select User and Before Creating a User for a Business Rule launched when creating a user:
**- or -**
select User and Before Updating a User for a Business Rule launched when updating a user account:
-
On the 3rd step, add the Run a program or PowerShell script action and paste the above script in the Script field.