0 votes

I have a 'Before user account creation' business rule that starts as follows:

If script 'Validate user exists' returns true then Do Nothing

// rest of validation occurs.

The script 'Validate user exists' has an LDAP filter to check if there exists a user account with the same sAMAccountName or Mail as the desired user creation and if so, throws '$Context.Cancel' and '$Context.ConditionIsMet = $False'.

In the adaxes SDK, it mentions "If your script is executed by a business rule that is triggered before an operation is performed, the $Context.Cancel method will cancel the execution of the operation. The method also cancels all business rule actions that are scheduled for execution after running the script.

I just had a case where the business rule fully executed itself (apparently ignoring the $Context.Cancel) but the user creation subsequently failed with the error 'The specified user account already exists'.

Regardless of the $Context.Cancel which should terminate the rest of the business rule, do I need to amend my initial validation block to resemble something like this?

If script 'Validate user exists' returns true then

Do Nothing

Else -> Adaxe operation : Cancel this operation

// rest of validation occurs.

Or am I experiencing a bug where $Context.Cancel is not properly terminating the business rule.

Thanks.

ago by (150 points)
0

Hello,

For troubleshooting purposes, please, provide a screenshot of the business rule in questions and the PowerShell script in TXT format.

Also, please, provide us with a screenshot of the Multi-server environment dialog. The dialog displays how many Adaxes services you have and what their versions are. For information on how to view it, see https://www.adaxes.com/help/MultiServerEnvironment.

You can post the data here or send to us at support@adaxes.com.

0

Hello, I just sent the screenshots to support@adaxes.com with the thread title as a subject.

2nd email with the powershell script in txt format.

Thanks!

1 Answer

0 votes
ago by (294k points)

Hello,

Thank you for the provided details. As it is mentioned in the documentation, the $Context.Cancel method is not available in conditions. As such, the behavior is expected. You need to make the script condition be met when the operation should be cancelled and use the Cancel this operation action instead of Do nothing.

Related questions

+1 vote
1 answer

Hi Adaxes Team I have created a business rule which sends a mail to our helpdesk staff after a user sets a new pw with the self password reset function. The user should ... . If this is not possible yet, please forward it as a suggestion :) regards pudong

asked Feb 4, 2022 by pudong (680 points)
0 votes
1 answer

Hi, I recall reading in documentation that business rules will be triggered also if changes are made in AD MMC or powershell. Right now the rules are triggered when changes ... so would there be any way to have business rules triggered in these cases? Thanks

asked Dec 7, 2017 by digimortal (240 points)
0 votes
1 answer

If I have a scheduled task powershell script that's targeting an OU of users and in that script I were to call $context.cancel in the case of an error happening for a single ... it cancel the entire scheduled tasks and it won't run for other users in that OU?

asked Oct 18 by wrichardson (20 points)
0 votes
1 answer

Hi team, I have a follow up to this question https://www.adaxes.com/questions/14234/business-after-adding-members-powershell-script-executed Let me explain my setup A rule- ... area% failed due to the following exception: $($_.Exception.Message)", "Error") }

asked Feb 13 by wintec01 (1.5k points)
0 votes
1 answer

Hi, I have a business rule setup to perform actions after user creation. First action is to run a powershell script which works and it sets a required AD attribute ( ... new user sits in the original OU and does not move Am i missing something here?

asked Feb 6 by Lewis (40 points)
3,588 questions
3,277 answers
8,303 comments
548,076 users