Skip to content

Enabling and disabling Security Roles

The following code sample shows how to enable and disable 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)

# Enable the role
$role.Disabled = $False
$role.SetInfo()

# Disable the role
$role.Disabled = $True
$role.SetInfo()

See also