Skip to content

General

The following code samples modify properties of a mail-enabled contact.

Alias

[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 contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"

# Set Alias
$contactParams.Alias = "%firstname,1%%lastname%"

# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

Use MAPI rich text format

[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 contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"

# Format for messages in the RTF format: 
# Use default settings of the client computer from which the message is sent
$contactParams.UseMapiRichTextFormat = "ADM_EXCHANGE_USEMAPIRICHTEXTFORMATTYPE_USEDEFAULTSETTINGS"
$contactParams.UseMapiRichTextFormatModificationEnabled = $True

# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

Hide from Exchange address lists

[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 contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"

# Hide from Exchange address lists
$contactParams.HiddenFromExchangeAddressList = $True

# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

Exchange custom attributes

[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 contact
$contactDN = "CN=My Contact,CN=Users,DC=domain,DC=com"
$contact = $admService.OpenObject("Adaxes://$contactDN", $NULL, $NULL, 0)

# Create an instance of the AdmExchangeMailContactParameters class
$contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters"

# Set Exchange attribute
$customAttributes = $contactParams.CustomAttributes
$customAttributes.IsModificationEnabled = $True
$customAttributes.SetCustomAttribute(1, "Date Modified: %datetime%")

# Save the changes
$contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")

See also