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

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

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

$myRole = $admService.OpenObject($myRoleAdsPath, $NULL, $NULL, 0)
$parentRole = $admService.OpenObject($parentRoleAdsPath, $NULL, $NULL, 0)

$myRole.ParentRoles.Add($parentRole)

See also