Hello,
Since the script creates users via Adaxes service, it triggers Business Rules on user creation and update. So, instead of sending for approval directly in the script, you can create a Business Rule triggered before creating a user for this purpose. To distinguish duplicate accounts from other new accounts, you can set a certain attribute of duplicate accounts to a certain value. Then, in your Business Rule, you can send the operation for approval only if the attribute is set to that specific value. As for an attribute that you can use, we suggest an Adaxes virtual attribute that stores boolean (True/False) values and set it to True. Such attributes are not stored in AD, but can be used the same as any other attributes of AD accounts.
To implement such a solution:
I. Change the script
To configure the script to set a virtual attribute to True when a duplicate account is being created, find the following block in the script:
<i class="text-italic"><s>if ($user -ne $NULL)
{
$Context.LogMessage("Cannot create user with Employee ID $($userProperties.EmployeeID). A user with the same Employee ID already exists.", "Error")
return
}</s></i>
and replace it with the following one:
<i class="text-italic">if ($user -ne $NULL)
{
# Duplicate account found
$userProperties.Add(<strong class="text-bold">"adm-CustomAttributeBoolean1"</strong>, $True)
}</i>
where adm-CustomAttributeBoolean1 is the LDAP display name of the virtual attribute you want to use.
II. Create a Business Rule that will sent the operation for approval
To create a Business Rule that will sent a new user for approval if the virtual attribute is set to True:
-
Create a new Business Rule.
-
On step 2 of the Create Business Rule wizard, select User and Before Creating a User.
-
On step 3, add the Send this operation for approval action.
-
Specify possible approvers and click OK.
-
Double-click Always.
-
Select If <property> <relation> <value>.
-
Specify If CustomAttributeBoolean1 equals true
where CustomAttributeBoolean1 is the name of the virtual attribute that you used in the script.
-
Click OK and finish creation of the Business Rule.