Skip to content

Delivery management

The following code sample configures a mail-enabled group to accept messages only within the group organization.

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

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

$messageDeliveryRestrictions = $groupParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$messageDeliveryRestrictions.RequireSenderAuthentication = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom.OverrideOldValues = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFromModificationEnabled = $True

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

The following code sample configures a mail-enabled group to accept messages from all senders.

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

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

$messageDeliveryRestrictions = $groupParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

$messageDeliveryRestrictions.RequireSenderAuthentication = $False
$messageDeliveryRestrictions.AcceptMessagesOnlyFrom.OverrideOldValues = $True
$messageDeliveryRestrictions.AcceptMessagesOnlyFromModificationEnabled = $True

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

The following code sample configures a mail-enabled group to accept messages only from a specific user.

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

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

$messageDeliveryRestrictions = $groupParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

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

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

$acceptMessagesOnlyFrom = $messageDeliveryRestrictions.AcceptMessagesOnlyFrom
$acceptMessagesOnlyFrom.OverrideOldValues = $False
$acceptMessagesOnlyFrom.Add("ADS_PROPERTY_APPEND", $objReference)

$messageDeliveryRestrictions.AcceptMessagesOnlyFrom = $acceptMessagesOnlyFrom

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

The following code sample configures a mail-enabled group to reject messages from a specific user.

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

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

$messageDeliveryRestrictions = $groupParams.MailFlowSettings.MessageDeliveryRestrictions
$messageDeliveryRestrictions.IsModificationEnabled = $True

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

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

$rejectMessagesFrom = $messageDeliveryRestrictions.RejectMessagesFrom
$rejectMessagesFrom.OverrideOldValues = $False
$rejectMessagesFrom.Add("ADS_PROPERTY_APPEND", $objReference)

$messageDeliveryRestrictions.RejectMessagesFrom = $rejectMessagesFrom

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

See also