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 (182k 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 (880 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

Hi, is there possibility to search some custom string across all powershell script files used in Adaxes? I.e. Custom commands, Scheduled tasks etc I need to find out where is used some PowerShell command to be able to replace it for another one..

asked Apr 27 by KIT (2.9k points)
0 votes
1 answer

Is it possible to only allow a user to unlock their account from the web interface? We have a group of Mac users who we'd like to be able to unlock their accounts through the web but use a different service for changing their passwords.

asked Jun 30 by scoutcor (650 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)
2,251 questions
2,011 answers
5,506 comments
24,818 users