Skip to content

Deleting Security Roles

The following code sample deletes a Security Role.

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

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

# By to 'My Role' Security role
$securityRolesPath = $admService.Backend.GetConfigurationContainerPath( `
    "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $securityRolesPath
$roleAdsPath = $securityRolesPathObj.CreateChildPath( `
    "CN=My Role")
$role = $admService.OpenObject($roleAdsPath, $NULL, $NULL, 0)

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

See also