0 votes

Hello!

I've made a simple business rule:

AFTER adding a member to a group
IF Operation Succeeded THEN
Send email notification

In the activity scope, I have selected the group in question, and selected "This Group Object".

However, when I add a user to the group, I get:

Business Rules: 1 rule encountered while processing your request
'Send DuoSecurity Info': Send e-mail notification (Info about DuoSecurity)
Resolving value references in the notification recipient address '%mail%' resulted in an empty string.
There are no recipients specified.

If I change the properties of the activity scope to "Members of this group", I get an "Operation Succeeded", but the business rule isn't triggered.
How do I make this work?

Regards,
Erlend

by (160 points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello Erlend,

The thing is that adding a member to a group means modifying the group, not the user, thus the %mail% value reference will be resolved into the e-mail of the group (if it has any), not the e-mail of the new member. To implement what you want, you need to send the e-mail message with the help of a script. For this purpose, add the Run a program or PowerShell script action to your Business Rule and paste the following script in the Script field:

$subject = "You have been added to Group %name%" # TODO: modify me
$bodyText = @"
Dear {0},

You have been added to group %name%.

Please do not reply to this e-mail, it has been sent to you for notification purposes only.
"@ # TODO: modify me

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

# Get email address of the new member
try
{
    $mail = $member.Get("mail")
}
catch
{
    return # No email address specified
}

# Insert the new member name in the e-mail body
$userFullName = $member.Get("name")
$body = [System.String]::Format($bodyText, $userFullName)

$Context.SendMail($mail, $subject, $body, $NULL)

In the script, modify the following to match your requirements:

  • $subject - specifies the e-mail message subject,
  • $bodyText - specifies a template for the e-mail message body. The {0} placeholder in the body will be replaced with the name of the new group member.

Related questions

0 votes
1 answer

Our Help Desk currently 'mirrors' the group membership of a new user based on another existing user in our AD. I'd like to be able to automate this so that the initiator ... and 'paste' it on the new user being created. Any help on this would be appreciated!

asked Apr 21, 2020 by RayBilyk (230 points)
0 votes
1 answer

Is there a report which shows users who are not a member of a specific group?

asked May 3, 2023 by dgilmour (20 points)
0 votes
1 answer

There is a script to indicated if a user is a member of any listed groups. Is it possible to have a version of the script that checks a group or member of any nested group? Current script page: https://www.adaxes.com/script-repositor ... s-s294.htm

asked Apr 30, 2018 by adaxes_user (420 points)
0 votes
1 answer

Hello, I have a web service that checks if a user is a member of a group. I am not concerned if they are a direct member or an indirect member of a group, but if the user is in the ... I pass it User A and Group 1. I am using ADSI, c# (.Net 4.0), and WCF.

asked Feb 23, 2014 by mbcalvin (140 points)
0 votes
1 answer

How can I create a script that does these things For internal audit. objective Even removing all groups of a disconnected user, we will still know which groups the ... in the created group (audit)-sAMAccountName-access add the (user)-sAMAccountName in members

asked Jul 2, 2022 by alancardoso (40 points)
3,340 questions
3,041 answers
7,764 comments
544,924 users