Script repository
The script adds objects stored in a DN-syntax property (e.g. See Also) of the target object to the specified group. The property is cleared at the end of the script. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.
Parameters
$groupDN- the distinguished name (DN) of the group to add members to. For information on how to get the DN, see Get the DN of a directory object.$attributeName- the name of the DN-syntax property to get members from.
$groupDN = "CN=My Group,OU=Groups,DC=domain,DC=com" # TODO: modify me
$attributeName = "seeAlso" # TODO: modify me
# Get attribute value.
try
{
$memberDNs = $Context.TargetObject.GetEx($attributeName)
}
catch
{
$Context.LogMessage("Property '$attributeName' is not specified for user %fullname%.", "Information")
return
}
# Add members to the group.
$group = $Context.BindToObjectByDN($groupDN)
foreach ($memberDN in $memberDNs)
{
$group.Add("Adaxes://$memberDN")
}
# Clear the attribute.
$Context.TargetObject.Put($attributeName, $NULL)
$Context.TargetObject.SetInfo()
Comments 0
You must be signed in to comment.