Skip to content

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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'Security Roles' container
$securityRolesPath = $admService.Backend.GetConfigurationContainerPath(`
    "AccessControlRoles")
$securityRolesContainer = $admService.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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'My Container' container
$securityRolesPath = $admService.Backend.GetConfigurationContainerPath(`
    "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $securityRolesPath
$myContainerPath = $securityRolesPathObj.CreateChildPath("CN=My Container")
$myContainer = $admService.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