IAdmTop6
The IAdmTop6 interface extends the IAdmTop interface with the ability to execute custom commands with specified parameters on an object.
Inheritance: IUnknown
Methods
-
Method
-
Description
-
ExecuteCustomCommand()
-
Executes a custom command with the given parameters on the object.
Details
ExecuteCustomCommand()
Executes a custom command with the given parameters on the object.
void ExecuteCustomCommand(String customCommandId, IAdmCustomCommandArguments arguments)
Parameters
-
customCommandId - Specifies the unique identifier of the custom command to be executed. To get the identifier, use the IAdmCustomCommand::CommandID property.
-
arguments - Specifies arguments for custom command execution. To create an instance of custom command arguments, use the IAdmCustomCommand2::CreateArguments method.
Examples
The following code sample executes a custom command with specified arguments on all users in an Organization Unit.
- PowerShell
-
[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) # 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) }
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; using Softerra.Adaxes.Interop.Adsi.CustomCommands; class Program { static void Main(string[] args) { // Connect to the Adaxes service AdmNamespace adsNS = new AdmNamespace(); IAdmService admService = adsNS.GetServiceDirectly("localhost"); // Bind to the custom command const string commandPath = "Adaxes://CN=My Command,CN=Custom Commands," + "CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"; IAdmCustomCommand2 command = (IAdmCustomCommand2)admService.OpenObject( commandPath, null, null, 0); // Specify arguments for command execution IAdmCustomCommandArguments commandArguments = command.CreateArguments(); commandArguments.SetParameterValue("MyParameter", "MyValue"); // Bind to the Organizational Unit const String containerPath = "Adaxes://OU=My OU,DC=domain,DC=com"; IADsContainer container = (IADsContainer)admService.OpenObject( containerPath, null, null, 0); // Execute the custom command for all users in the Organizational Unit container.Filter = new object[] { "user" }; foreach (IAdmTop6 user in container) { user.ExecuteCustomCommand(command.CommandID, commandArguments); } } }
Requirements
Minimum required version: 2018.2