Skip to content

Creating Custom Command containers

The following code sample creates a container for Custom Commands.

[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 Commands' container
$customCommandsPath = $admService.Backend.GetConfigurationContainerPath(
    "CustomCommands")
$customCommandsContainer = $admService.OpenObject($customCommandsPath,
    $NULL, $NULL, 0)

# Create container
$myContainer = $customCommandsContainer.Create("container","CN=My Container")
$myContainer.SetInfo()

The following code sample creates a Custom Command in a specific container.

[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 'My Container' container
$customCommandsPath = $admService.Backend.GetConfigurationContainerPath(
    "CustomCommands")
$customCommandsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $customCommandsPath
$myContainerPath = $customCommandsPathObj.CreateChildPath("CN=My Container")
$myContainer = $admService.OpenObject($myContainerPath, $NULL, $NULL, 0)

# Create a new Custom Command
$command = $myContainer.Create("adm-CustomCommand", "CN=My Command")

$command.ObjectType = "user"
$command.Confirmation = "Are you sure?"
$command.CommandIcon = 7

$command.Description = "My description"
$command.Disabled = $False

$command.ExecutionMoment = "ADM_BUSINESSRULEEXECMOMENT_BEFORE"
$command.OperationType = "none"

# Save the Custom Command
$command.SetInfo()

See also