Deleting security roles

The following code sample deletes a security role.

[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 role
$securityRolesPath = $service.Backend.GetConfigurationContainerPath("AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $securityRolesPath
$roleAdsPath = $securityRolesPathObj.CreateChildPath("CN=My Role")

$role = $service.OpenObject($roleAdsPath, $null, $null, 0)

# Delete the role
$role.DeleteObject("ADM_DELETEOBJECTFLAGS_AUTO")

See also