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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the 'Custom Commands' container
$customCommandsPath = $service.Backend.GetConfigurationContainerPath(
"CustomCommands")
$customCommandsContainer = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the 'My Container' container
$customCommandsPath = $service.Backend.GetConfigurationContainerPath(
"CustomCommands")
$customCommandsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
$customCommandsPath
$myContainerPath = $customCommandsPathObj.CreateChildPath("CN=My Container")
$myContainer = $service.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
- Managing custom commands
- Binding to Adaxes-specific objects
- Managing Adaxes-specific objects
- IADs
- IADsContainer
- IAdmCustomCommand
- Online script repository