Inheriting security roles

The following code sample inherits a security role from another security role.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

$securityRolesPath = $service.Backend.GetConfigurationContainerPath( `
    "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $securityRolesPath

$myRoleAdsPath = $securityRolesPathObj.CreateChildPath("CN=My Role")
$parentRoleAdsPath = $securityRolesPathObj.CreateChildPath( `
    "CN=Parent Role")

$myRole = $service.OpenObject($myRoleAdsPath, $null, $null, 0)
$parentRole = $service.OpenObject($parentRoleAdsPath, $null, $null, 0)

$myRole.ParentRoles.Add($parentRole)

See also