Skip to content

Message approval

The following code sample enables moderation of messages sent to a mail-enabled 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 group
$groupDN = "CN=MyGroup,CN=Users,DC=example,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

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

$messageModeration = $groupParams.MailFlowSettings.MessageModeration
$messageModeration.IsModificationEnabled = $True
$messageModeration.ModerationEnabled = $True

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

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

$moderatedBy = $messageModeration.ModeratedBy
$moderatedBy.OverrideOldValues = $False
$moderatedBy.Add("ADS_PROPERTY_APPEND", $objReference)

$messageModeration.ModeratedBy = $moderatedBy
$messageDeliveryRestrictions.RejectMessagesFrom = $rejectMessagesFrom

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

This code code sample sets a list of senders who don’t require message approval.

[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 AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"

$messageModeration = $groupParams.MailFlowSettings.MessageModeration
$messageModeration.IsModificationEnabled = $True

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

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

$bypassModerationFrom = $messageModeration.BypassModerationFrom
$bypassModerationFrom.OverrideOldValues = $False
$bypassModerationFrom.Add("ADS_PROPERTY_APPEND", $objReference)

$messageModeration.BypassModerationFrom = $bypassModerationFrom

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

The following code sample enables notifying all senders of unapproved messages.

[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 AdmExchangeMailGroupParameters class
$groupParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailGroupParameters"

$messageModeration = $groupParams.MailFlowSettings.MessageModeration
$messageModeration.IsModificationEnabled = $True

# Notify all senders
$messageModeration.SendModerationNotificationType = 
"ADM_EXCHANGE_SENDMODERATIONNOTIFICATIONTYPE_ALWAYS"

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

See also