Hello Ryan,
All users get added to the Piction Silver group because all conditions are resolved before executing the Scheduled Task. There is no possibility to group the actions/conditions to achieve what you need. We recommend using a Business Rule triggering After Creating a User and the following PowerShell script:
# First Group Settings
$firstGroupDN = "CN=FirstGroup,OU=Groups,DC=domain,DC=com" # TODO: modify me
$firstGroupContainers = @("OU=IT,OU=Users,DC=domain,DC=com", "OU=Sales,OU=Users,DC=domain,DC=com") # TODO: modify me
# Second Group Settings
$secondGroupDN = "CN=SecondGroup,OU=Groups,DC=domain,DC=com" # TODO: modify me
$secondGroupContainers = @("OU=Marketing,OU=Users,DC=domain,DC=com", "OU=Administrators,OU=Users,DC=domain,DC=com") # TODO: modify me
# Third Group Settings
$thirdGroupDN = "CN=ThirdGroup,OU=Groups,DC=domain,DC=com" # TODO: modify me
function IsLocatedUnderContainers($userDN, $containersDNs)
{
foreach ($dn in $containersDNs)
{
if ($userDN.IsDescendantOf($dn))
{
return $True
}
}
return $False
}
# Check conditions for First group
$userDN = New-Object Softerra.Adaxes.Ldap.DN "%distinguishedName%"
if ("%title%" -eq "Graphic Designer" -or
"%title%" -eq "Print/Digital Designer" -or
(IsLocatedUnderContainers $userDN $firstGroupContainers))
{
# Add to first group
$group = $Context.BindToObjectByDN($firstGroupDN)
$group.Add($Context.TargetObject.AdsPath)
}
elseif (IsLocatedUnderContainers $userDN $secondGroupContainers)
{
# Add to second group
$group = $Context.BindToObjectByDN($secondGroupDN)
$group.Add($Context.TargetObject.AdsPath)
}
else
{
# Add to third group
$group = $Context.BindToObjectByDN($thirdGroupDN)
$group.Add($Context.TargetObject.AdsPath)
}
In the script:
- $firstGroupDN, $secondGroupDN, $thirdGroupDN – Specify distinguished names of Platinum, Gold and Silver groups accordingly;
- $firstGroupContainers – Specifies distinguished names of OUs where the user should be located to be added to the Platinum group;
- $secondGroupContainers – Specifies distinguished names of OUs where the user should be located to be added to the Gold group.
To create the Business Rule:
- Launch Adaxes Administration Console.
- Right-click your Adaxes service node, navigate to New and click Business Rule.
- On step 2 of the Create Business Rule wizard, select User Object type.
- Select After Creating a User and click Next.
- Click Add Action.
- Select Run a program or PowerShell script.
- Paste the script into the Script field.
- Enter a short description and click OK.
- Click Next and finish creating the Business Rule.