0 votes

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 group. The following script is executed, but it doesn't check the number. Am i missing something?

Import-Module Adaxes

if ($Context.IsPropertyModified("gidNumber"))
{
    # Get the value
    $value = $Context.GetModifiedPropertyValue("gidNumber")

    # Validate the value
    if (([System.String]::IsNullOrEmpty($value)) -or (-not($value.Contains("-"))))
    {
        $Context.Cancel("Ungültige Team-Nummer!")
        return
    }

    # Check whether the value is unique
    if ((Get-AdmGroup -Filter 'gidNumber -eq $value') -ne $NULL)
    {
        $Context.Cancel("Ein Team mit dieser Team-Nummer existiert bereits!")
        return
    }
}
by (160 points)
0

Hello,

The script looks just fine. For us to help you with a solution, please, specify the following:

  • Where exactly is the script executed? Is it a Business Rule triggering Before updating a group or Before creating a group? Could you, please, post here or send us (support[at]adaxes.com) a screenshot?
  • What exactly do you mean by it doesn't check the number?
  • Do you face any error messages? If so, please, post here or send us (support[at]adaxes.com) screenshots.
  • Is gidNumber the LDAP name of the property or its display name?
0

The script is in a custom command. I have a business rule triggering before creating a group, which executes the custom command, with scope on all objects

Every team has a number set in the attribute gidNumber image.png

This number has to be unique, no other team should have the same number.

In case a new team (group) is created, the gidNumber of all existing teams must be checked. If the gidNumber of the new team already exists on another team, there should be an error.

Now, the business rule triggers, the script is executed and gives me no error. I can create a team with an existing gidNumber, without an error.

1 Answer

0 votes
by (294k points)

Hello,

To achieve the desired behavior, you need to move the script into the Business Rule triggering Before creating a group. It will never work in a Custom Command. Also, you need to remove the check for dashes being present in the property value as it is an integer property and it cannot have dashes. Find the updated script below.

Import-Module Adaxes

if ($Context.IsPropertyModified("gidNumber"))
{
    # Get the value
    $value = $Context.GetModifiedPropertyValue("gidNumber")

    # Validate the value
    if ([System.String]::IsNullOrEmpty($value))
    {
        $Context.Cancel("Ungültige Team-Nummer!")
        return
    }

    # Check whether the value is unique
    if ((Get-AdmGroup -Filter 'gidNumber -eq $value') -ne $NULL)
    {
        $Context.Cancel("Ein Team mit dieser Team-Nummer existiert bereits!")
        return
    }
}

Related questions

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

Hi, I'd like to implement a rule to ensure that telephoneNumber value is unique accross the domain for each user, either after creation or updates. I tried to implement a ... one (before change). How to get the new value in the script ? Thanks Stephen

asked May 31, 2011 by sroux (800 points)
0 votes
1 answer

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.

asked Mar 2, 2022 by Keonip (180 points)
0 votes
1 answer

I’m looking for a way to take a unique number from Adaxes and use part of it to create an employee ID for the AD attribute field.

asked Dec 25, 2023 by cewilson (190 points)
0 votes
1 answer

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12, 2022 by A_Pastor (70 points)
3,588 questions
3,277 answers
8,303 comments
548,091 users