0 votes

Hi,

I followed this example: https://www.adaxes.com/sdk/IAdmTop6.html, but because the Custom Command is disabled, I get the following error message:

System.Management.Automation.MethodInvocationException:
Exception calling "ExecuteCustomCommand" with "2" argument(s): "Custom command '<the name of the custom command>' is disabled." 
---> System.InvalidOperationException: Custom command '<the name of the custom command>' is disabled. 
at Softerra.Adaxes.Adsi.AdmObjectPipelined.ExecuteCustomCommand(String customCommandIdArg, IAdmCustomCommandArguments argumentsArg) 
at CallSite.Target(Closure , CallSite , Object , Object , Object ) 
--- End of inner exception stack trace --- 
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) 
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) 
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

The Custom Command should not be available directly through the context menu, since it is meant to only be execuded by a script, another custom command, or some other form of automation.

For clarity, It works if I enable the Custom Command.

I am using Adaxes 2018.2

Best Regards Martin

by (280 points)

1 Answer

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

Hello Martin,

Unfortunately, it is not possible. Disabled Custom Commands can only be executed in Business Rules, Scheduled Tasks and other Custom Commands. As a solution, you can first enable the command in your script and then disable it after execution as in the below example.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the Custom Command
$commandDN = "CN=My Command,CN=Custom Commands,CN=Configuration Objects,"+
    "CN=Adaxes Configuration,CN=Adaxes"
$command = $admService.OpenObject("Adaxes://$commandDN", $NULL, $NULL, 0)

# Enable Custom Command
$command.Disabled = $False
$command.SetInfo()

# Specify arguments for command execution
$commandArguments = $command.CreateArguments()
$commandArguments.SetParameterValue("MyParameter", "MyValue")

# Bind to the Organizational Unit
$containerDN = "OU=My OU,DC=domain,DC=com"
$container = $admService.OpenObject("Adaxes://$containerDN", $NULL, $NULL, 0)

# Execute the Custom Command for all users in the Organizational Unit
$container.Filter = @("user")

foreach ($user in $container)
{
    $user.ExecuteCustomCommand($command.CommandID, $commandArguments)
}

# Disable Custom Command
$command.Disabled = $True
$command.SetInfo()
0

Hi,

Thank you for the quick reply, this solves my problem.

Related questions

0 votes
1 answer

I'd like to be able to either send an email report or export a CSV of all of the business rules carried out when a user is disabled. This would be ... Management Activity section but this includes things that weren't part of the disable operation. Thanks

asked Feb 19, 2020 by bavery (1.3k points)
0 votes
1 answer

Is it possible to call execution of Adaxes custom command via SPML?

asked Oct 16, 2019 by Dmytro.Rudyi (4.1k points)
0 votes
1 answer

I have a dropdown-field on the web surface, which is populated by a script. The script looks up all groups in a specific OU and displays them. In the Property Pattern ... random order. What should i do to show the groups in alphabetical order in the portal?

asked Sep 15, 2020 by lohnag (1.1k points)
0 votes
1 answer

We have a process that when a new user is created they are emailed their username and apssword. If the user is in an Admin Group they are then sent an email with some PDFs ... you can send emails, but am unable to see where it could attach files to the email?

asked Sep 3, 2020 by dknapp (690 points)
0 votes
1 answer

I would like the HR to be able to set the date of deprovision User. So that it's executed on set date and not on command. I Tryed with parameter (Date/Time picker) ... it possible with custom command or do i have to make Scheduled Task with (Date/time picker)?

asked Jan 20 by Sandberg94 (450 points)
2,414 questions
2,165 answers
5,832 comments
228,771 users