We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Notify manager about adding user to group

The script notifies a user manager about adding the user to a group. To use the script with Adaxes, create a business rule that runs it after adding a member to a group. To add the script to your rule, use the Run a program or PowerShell script action.

Parameters:

  • $subject - Specifies a template for the email notification subject.
  • $message - Specifies a template for the email notification message.
    You can use value references (e.g. the %name%, %adm-ParentName%) in the message and subject templates. Value references will be replaced with corresponding property values of the group. The {0} placeholder will be replaced with the name of the added user.
Edit Remove
PowerShell
$subject = "User {0} added to group '%name%'" # TODO: modify me
$message = "User {0} added to group '%name%'" # TODO: modify me

# Bind to member
$member = $Context.BindToObject("Adaxes://%member%")

if ($member.Class -ne "user")
{
    return
}

# Get manager
try
{
    $managerDN = $member.Get("manager")
}
catch
{
    return # Manager not specified
}

# Get manager mail
$manager = $Context.BindToObjectByDN($managerDN)
try
{
    $managerMail = $manager.Get("mail")
}
catch
{
    $managerName = $manager.Get("name")
    $Context.LogMessage("Could not notify the user's manager because the manager ('$managerName') does not have an e-mail address", "Warning") # TODO: modify me
    return
}

# Send notification
$memberName = $member.Get("name")
$subject = [System.String]::Format($subject, $memberName)
$message = [System.String]::Format($message, $memberName)
$Context.SendMail($managerMail, $subject, $message, $NULL)
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers