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 (174k 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 by bavery (250 points)
0 votes
1 answer

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

asked Oct 16, 2019 by Dmytro.Rudyi (2.8k points)
0 votes
0 answers

Before Deactivation of an Account on the Webinterface our Help Desk need to change the AD User Description manually. Is it possible to force a manual change before deactivation ?

asked Feb 7 by lv01 (250 points)
0 votes
1 answer

We're trying to setup a new action in our Web interface that runs on User's that are currently in an OU called 'New Starters' that is in all of our domains (An ... no results, There are no other fields we can use that are unique to accounts in those OUs

asked Feb 7 by richarddewis (1.3k points)
0 votes
1 answer

Hello, I have a small question about executing custom commands remotely with powershell. We are now using Adaxes custom commands through orchestrator with remote ... /$UserAD_DN", $NULL, $NULL, 0) $UserAD.ExecuteCustomCommand($command_example) Kr, Serge

asked Oct 12, 2015 by kerremansserge (1.4k points)
2,135 questions
1,900 answers
5,319 comments
3,538 users