0 votes

Fresh install of Adaxes, version 2023.2

Testing out creating a user in Active Directory and I found a simple script to check if the username and email is unique. This rule is set to run before creating the user.

Code is below

# Build criteria
if (-not([System.String]::IsNullOrEmpty("%mail%")))
{
    $expression = {sAMAccountName -eq "%username%" -or mail -eq "%mail%"}
}
else
{
    $expression = {sAMAccountName -eq "%username%"}
}
$criteria = New-AdmCriteria -Type "user" -Expression $expression

# Search for users with the username or email address specified
$searcher = $Context.TargetObject
$searcher.Criteria = $criteria
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.VirtualRoot = $True
$searcher.SizeLimit = 1

try
{
    $searchResultIterator = $searcher.ExecuteSearch()
    $searchResults = $searchResultIterator.FetchAll()

    if ($searchResults.Length -ne 0)
    {
        $Context.Cancel("A user with the same username or email address already exists")
        return
    }
}
finally
{
    # Release resources
    $searchResultIterator.Dispose()
}

I create the business rule and can run the script successfully when creating the rule however when attempting to create a user I get the error:

image.png

The service account configured in Adaxces has been delegated permission for a staging OU however this script isnt writing to the domain so delegation shouldn't be required

ago by (20 points)
0

Hello,

For troubleshooting purposes, please, sign in with the credentials of the Adaxes service account (specified during Adaxes installation) and try creating a user in the same OU. Does it work fine?

Please log in or register to answer this question.

Related questions

0 votes
1 answer

I'm trying to create a business rule that is executed before a user is created. I used the Adaxes tutorial Run PowerShell Script after Creating a User for ... execute. Are there permissions I'm forgetting somewhere? Thanks in advance for the assistance.

asked Jun 29, 2021 by lgibbens (320 points)
0 votes
1 answer

The closest operation I figure is "modfying exchange properties" of a user but not sure how I can filter the conditions to match. It's possible I could ... ? Was also looking at adm-MsExchMailboxCalendarPermissions but havent played around with that yet.

asked May 17, 2024 by ZoomGhost (280 points)
0 votes
1 answer

We have AD groups that manage what VLAN a user's system is associated with based on the user's department. I have custom command to change the PC group membership if the ... business rule. (I cannot select the command) is there a way to work around this?

asked Feb 27 by stevehalvorson (150 points)
0 votes
1 answer

Hi, I need to retreive a secret from a Azure Keyvault in a business rule. I have a powershell script that works if i run a external command. But it fails if ... at <ScriptBlock>, <No file>: line 20 Any sugestion? Kind regards Reidar Dick-Henriksen

asked Dec 6, 2023 by reidardh (20 points)
0 votes
1 answer

Hello, I am attempting to configure a business rule that adjusts an adaxes custom property of a user, upon that user being added/removed from a group. I cannot seem to ... (like username, office, description, email, etc.) but not so much on custom attributes.

asked Jul 14, 2023 by NKB#2772 (70 points)
3,708 questions
3,390 answers
8,565 comments
549,810 users