Creating security role containers

The following code sample creates a container for security roles.

[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 'Security Roles' container
$securityRolesPath = $service.Backend.GetConfigurationContainerPath(`
    "AccessControlRoles")
$securityRolesContainer = $service.OpenObject($securityRolesPath,
     $null, $null, 0)

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

The following code sample creates a security role 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
$securityRolesPath = $service.Backend.GetConfigurationContainerPath(`
    "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $securityRolesPath
$myContainerPath = $securityRolesPathObj.CreateChildPath("CN=My Container")
$myContainer = $service.OpenObject($myContainerPath,
     $null, $null, 0)

# Create security role
$role = $myContainer.Create("adm-Role", "CN=My Role")

$role.Description = "My description"
$role.Disabled = $false
$role.SetInfo()

See also