Skip to content

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