Skip to content

IAdmTop6

The IAdmTop6 interface extends the IAdmTop interface with the ability to execute Custom Commands with specified parameters on an object.

Inheritance: The IAdmTop6 interface inherits from the IUnknown interface.

Methods

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.

[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)
}
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

See also