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
$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"

$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
$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"

$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
$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"

$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