0 votes

So this works for us however we would like to add to check if the last group is at 3 users we would like to send a seperate email but would still like all the above to continue to happen the way it is.

related to an answer for: Can you load balance security groups?
by (160 points)
0

Hello,

Sorry for the confusion, but we are not sure what exactly you mean. Do you need to send an email notification when the third member is added to a specific group? If that is not it, please, describe the desired behaviour in all the possible details with live examples.

0

In my last question a script was created to send a email when all groups are full I want a seperate email sent if the last group is more than 75% full

0

Hello,

Thank you for clarifying. Could you, please, also specify what needs to be included into the email? A live example of the notification will be much appreciated.

0

Subject = WARNING: ALL TS SECURITY GROUPS FOR %company% ARE ALMOST FULL. Body = The last TS security group for %company% is currently greater than 75 percent full.

0

Hello,

Do we understand correctly that %company% stands for the value of the company property of the user being created?

0

Yes

1 Answer

0 votes
by (227k points)

Hello,

Thank you for all the provided details. Here is the script you can use to send the email notification. It should be executed after the existing script in the business rule triggering After creating a user. In the script:

  • $membersLimit - Specifies the maximum number of members the last non-full group should reach for the email to be sent.
  • $groupDNs - Specifies distinguished names (DNs) of the groups taking part in the workflow. For information on how to get an object DN, see https://adaxes.com/sdk/HowDoI.GetDnOfObject. Must be the same as $groupDNs in the first script executed in the business rule triggering After creating a user.
  • $to - Specifies the recipient of the email notification.
  • $subject - Specifies the subject of the email notification. You can use value references in the subject. For example, to add the value of the user company property, use %company%.
  • $body - Specifies the body of the email notification. You can use value references in the body. For example, to add the value of the user company property, use %company%.
$membersLimit = 3 # TODO: modify me
$groupDNs = @("CN=Group 1,OU=Groups,DC=domain,DC=com", "CN=Group 2,OU=Groups,DC=domain,DC=com") # TODO: modify me

# Mail settings
$to = "recipient@domain.com" # TODO: modify me
$subject = " WARNING: ALL TS SECURITY GROUPS FOR %company% ARE ALMOST FULL." # TODO: modify me
$body = @"
The last TS security group for %company% is currently greater than 75 percent full.
"@ # TODO: modify me

# Add user to a group
$groupsReachedLimit = @()
foreach ($groupDN in $groupDNs)
{
 # Bind to the group
 $group = $Context.BindToObjectByDN($groupDN)

 # Get group members
 try
 {
     $groupMembers = $group.GetEx("adm-DirectMembersGuid")
 }
 catch
 {
     return
 }

 # Check number of members
 if ($groupMembers.Length -eq $membersLimit)
 {
    $groupsReachedLimit += $groupDN
 }    
}

# Send mail
if ($groupsReachedLimit.Length -eq 1)
{
    $Context.SendMail($to, $subject, $body, $NULL)
}

Related questions

0 votes
1 answer

We want to check, if the number of a new team (group) is unique. The number is stored in the attribute "gidNumber". I have a business rule executing before creating ... $NULL) { $Context.Cancel("Ein Team mit dieser Team-Nummer existiert bereits!") return } }

asked Oct 13, 2020 by lohnag (100 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

Is there a way to receive an email if a FAILED operation status is logged to Logging?

asked Jun 29, 2016 by casey.cochran (20 points)
0 votes
1 answer

Hi, I need to run a schedule task only if a customattribute is not empty. Can I use ConditionIsMet?

asked Oct 7, 2021 by Simone.Vailati (270 points)
0 votes
1 answer

I would like to on a monthly basis to email the group owner the members of each group they own for verification pruposes. i would need the group name and the name of the members.

asked Jun 3, 2021 by Derek.Axe (440 points)
2,797 questions
2,530 answers
6,594 comments
56,836 users