Skip to content

Creating groups

Create a Global Security group

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

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

# Bind to the target container
$containerDN = "CN=Users,DC=domain,DC=com"
$container = $admService.OpenObject("Adaxes://$containerDN", `
    $NULL, $NULL, 0)

# Create group
[Softerra.Adaxes.Interop.Adsi.ADS_GROUP_TYPE_ENUM]$groupType =
    "ADS_GROUP_TYPE_GLOBAL_GROUP, ADS_GROUP_TYPE_SECURITY_ENABLED"

$group = $container.Create("group","CN=New Group")
$group.Put("groupType", [Int32]$groupType)
$group.SetInfo()
Import-Module Adaxes

$containerDN = "CN=Users,DC=domain,DC=com"

New-AdmGroup -Name "New Group" -Path $containerDN `
    -GroupCategory Security -GroupScope Global `
    -Server "domain.com" -AdaxesService localhost

Create a Local Distribution group

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

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

# Bind to the target container
$containerDN = "CN=Users,DC=domain,DC=com"
$container = $admService.OpenObject("Adaxes://$containerDN", `
    $NULL, $NULL, 0)

# Create group
[Softerra.Adaxes.Interop.Adsi.ADS_GROUP_TYPE_ENUM]$groupType = 
    "ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP"

$group = $container.Create("group","CN=New Group")
$group.Put("groupType", [Int32]$groupType)
$group.SetInfo()
Import-Module Adaxes

$containerDN = "CN=Users,DC=domain,DC=com"

New-AdmGroup -Name "New Group" -Path $containerDN `
    -GroupCategory Distribution -GroupScope DomainLocal `
    -Server "domain.com" -AdaxesService localhost

See also