Delegation

The following code sample sets Send As delegates for a mail-enabled group.

[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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# Create an instance of the 'AdmExchangeMailGroupParameters' class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"

$sendAs = $groupParams.SendAs
$sendAs.OverrideOldValues = $false

$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $userDN

$sendAs.Add("ADS_PROPERTY_APPEND", $objReference)
$groupParams.SendAs = $sendAs

# Save changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

The following code sample sets Send on Behalf Of delegates for a mail-enabled group.

[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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# Create an instance of the 'AdmExchangeMailGroupParameters' class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"

$sendOnBehalfOf = $groupParams.GrantSendOnBehalfTo
$sendOnBehalfOf.OverrideOldValues = $false

$userDN = "CN=John Smith,CN=Users,DC=example,DC=com"

$objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
$objReference.ObjectDN = $userDN

$sendOnBehalfOf.Add("ADS_PROPERTY_APPEND", $objReference)
$groupParams.GrantSendOnBehalfTo = $sendOnBehalfOf

# Save changes
$group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

See also