Performing Exchange tasks
To create an Exchange mailbox for a user, you need to use the IAdmExchangeMailboxOps interface, which is implemented by all ADSI objects representing users. In order to get this interface, you need to bind to the user object in Active Directory.
To create a mailbox, call the CreateMailbox
method of the interface. The first parameter of the method specifies the mailbox alias. The alias can be a combination of characters separated by a period with no intervening spaces. You can use value references in the mailbox alias, for example, %username%. Value references will be replaced with corresponding property values of the user account.
The second parameter of the method specifies the ADS path of the database where the new mailbox will be created. The ADS path should be formatted as Adaxes://<DatabaseDN>, where <DatabaseDN> is the distinguished name (DN) of the mailbox database. For details on how to get the DN of a mailbox database, see Get the DN of a mailbox database.
The following code sample creates an Exchange mailbox for a user.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $alias = "%username%" $mailboxDatabaseDN = "CN=DB 1,CN=Databases,CN=Exchange Administrative Group," + "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," + "CN=Services,CN=Configuration,DC=domain,DC=com" # Bind to user object $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Create a mailbox $user.CreateMailbox($alias, "Adaxes://$mailboxDatabaseDN")
- C#
-
using System; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); const string userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"; const string alias = "%username%"; const string mailboxDatabaseDN = "CN=DB 1,CN=Databases,CN=Exchange Administrative Group," + "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," + "CN=Services,CN=Configuration,DC=domain,DC=com"; // Bind to user object IADs user = (IADs)service.OpenObject("Adaxes://" + userDN, null, null, 0); // Create a mailbox IAdmExchangeMailboxOps mailboxOps = (IAdmExchangeMailboxOps)user; mailboxOps.CreateMailbox(alias, "Adaxes://" + mailboxDatabaseDN); } }
Moving mailboxes
To move Exchange mailboxes between databases, use the CreateMoveMailboxRequest method of the IAdmMoveExchangeMailboxOps interface, which is implemented by all ADSI objects representing Active Directory user accounts.
The CreateMoveMailboxRequest
method moves mailboxes asynchronously, meaning that the method call will return before the mailbox move is completed.
The method allows you to move the primary mailbox and/or the archive mailbox of a user. If you want to move the primary mailbox, specify the ADS path of the target mailbox database as the first parameter of the method. If you don't want to move the primary mailbox, pass null
to the parameter. The ADS path should be formatted as Adaxes://<DatabaseDN>, where <DatabaseDN> is the distinguished name (DN) of the target mailbox database. For details on how to get the DN of a mailbox database, see Get the DN of a mailbox database.
The following code sample moves the primary mailbox of a user to the mailbox database called DB 2.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $targetDatabaseDN = "CN=DB 2,CN=Databases,CN=Exchange Administrative Group," + "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," + "CN=Services,CN=Configuration,DC=domain,DC=com" # Bind to user object $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Move the mailbox $user.CreateMoveMailboxRequest("Adaxes://$targetDatabaseDN", $null, 0, 0)
- C#
-
using System; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); const string userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"; const string targetDatabaseDN = "CN=DB 2,CN=Databases,CN=Exchange Administrative Group," + "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," + "CN=Services,CN=Configuration,DC=domain,DC=com"; // Bind to user object IADs user = (IADs)service.OpenObject("Adaxes://" + userDN, null, null, 0); // Move the mailbox IAdmMoveExchangeMailboxOps moveOps = (IAdmMoveExchangeMailboxOps)user; moveOps.CreateMoveMailboxRequest("Adaxes://" + targetDatabaseDN, null, 0, 0); } }
Moving mailboxes to/from Microsoft 365
You can use the IAdmMoveExchangeMailboxOps2 interface to move mailboxes between on-premises Exchange and Microsoft 365. However, it is available on the server side only and can be used in scripts executed via business rules, custom commands, and scheduled tasks.
Exporting mailboxes
To export the primary mailbox of a user to a Personal Storage Table (PST) file, you need to call the CreateMailboxExportRequest method of the IAdmExportExchangeMailboxOps interface supported by all user objects. The first parameter of the method specifies the full UNC path to the exported PST file. The method will return an export request ID that can be used to check the status of the request. To check the status, use the GetMailboxExportRequestInfo
method of the same interface.
The CreateMailboxExportRequest
method exports mailboxes asynchronously, meaning that the method call will return before the mailbox export is completed.
The following code sample exports a user's mailbox to PST.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $filePath = "\\SERVER\Backups\JSmith.pst" # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the user $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Export the mailbox $requestId = $user.CreateMailboxExportRequest($filePath, 0, 0) # Get mailbox export request info $requestInfo = $user.GetMailboxExportRequestInfo($requestId, $false) while($requestInfo.Status -eq "ADM_EXPORTMAILBOXSTATUS_INPROCESS") { Start-Sleep -Seconds 30 $requestInfo = $user.GetMailboxExportRequestInfo($requestId, $false) } # Status Write-Host "Status: " -NoNewline switch ($requestInfo.Status) { "ADM_EXPORTMAILBOXSTATUS_SUCCEEDED" { Write-Host "The mailbox has been exported successfully" } "ADM_EXPORTMAILBOXSTATUS_FAILED" { Write-Host $requestInfo.FailureMessage } }
- C#
-
using System; using System.Threading; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { const string userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"; const string filePath = @"\\SERVER\Backups\JSmith.pst"; // Connect to the Adaxes service AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the user IAdmExportExchangeMailboxOps user = (IAdmExportExchangeMailboxOps)service.OpenObject( "Adaxes://" + userDN, null, null, 0); // Export the mailbox string requestId = user.CreateMailboxExportRequest(filePath, 0, 0); // Get mailbox export request info IAdmExportExchangeMailboxRequestInfo requestInfo = user.GetMailboxExportRequestInfo(requestId, false); while (requestInfo.Status == ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_INPROCESS) { Thread.Sleep(30000); requestInfo = user.GetMailboxExportRequestInfo(requestId, false); } Console.Write("Status: "); switch (requestInfo.Status) { case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_SUCCEEDED: Console.WriteLine("The mailbox has been exported successfully."); break; case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_FAILED: Console.WriteLine(requestInfo.FailureMessage); break; } } }
Mail-enabling contacts and groups
In order to establish an e-mail address in Exchange for a group, contact, or user, you need to call the MailEnable
method of the IAdmExchangeMailOps interface, which is supported by all ADSI objects representing groups, contacts, and users. For details on how to bind to directory objects, see Binding to ADSI objects.
The first parameter of the MailEnable
method specifies the e-mail alias. You can use value references in the alias, for example, %username%, or %firstname%%lastname%. Value references will be replaced with corresponding property values of the directory object the method is called on.
When mail-enabling a user or contact, you need to pass the external email address as the second parameter, and the type of the email address as the third parameter of the method. When mail-enabling a group, both parameters must be null
.
The following code sample mail-enables a group in Exchange.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to group object $groupDN = "CN=My Group,CN=Groups,DC=domain,DC=com" $group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0) # Mail-enable the group $alias = "%username%" $group.MailEnable($alias, $null, $null, $null)
- C#
-
using System; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to group object const string groupDN = "CN=My Group,CN=Groups,DC=domain,DC=com"; IADs group = (IADs)service.OpenObject("Adaxes://" + groupDN, null, null, 0); // Mail-enable the group const string alias = "%username%"; IAdmExchangeMailOps mailOps = (IAdmExchangeMailOps)group; mailOps.MailEnable(alias, null, null, null); } }
Accessing Exchange properties
To get properties of a mailbox, mail-enabled contact or distribution list, first you need to bind to the object. All user, group, and contact objects support the IAdmExchangeMailParametersOps interface, using which you can access object's Exchange properties by calling the GetMailParameters method of the interface.
Calling the GetMailParameters
method is expensive with regard to performance, as it fetches all Exchange-related information of an object.
The following code sample gets the alias of a mailbox.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to user object $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Read Exchange properties $exchangeProps = $user.GetMailParameters() # Get the alias $alias = $exchangeProps.Alias Write-Host "Alias:" $alias
- C#
-
using System; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user object IADs user = (IADs)service.OpenObject( "Adaxes://CN=John Smith,CN=Users,DC=company,DC=com", null, null, 0); // Read Exchange properties IAdmExchangeMailParametersOps exchangeOps = (IAdmExchangeMailParametersOps)user; IAdmExchangeMailParameters exchangeProps = exchangeOps.GetMailParameters(); // Get the alias string alias = exchangeProps.Alias; Console.WriteLine("Alias: " + alias); } }
The GetMailParameters
method returns the IAdmExchangeMailParameters interface, which is common for mailboxes, mail-enabled contacts, and distribution lists. The table below shows additional interfaces that are supported by various Exchange recipient types.
Recipient Type | Interface |
---|---|
Mailbox | IAdmExchangeMailboxParameters |
Mail-enabled contact | IAdmExchangeMailContactParameters |
Mail-enabled group | IAdmExchangeMailGroupParameters |
It means that if you need to access Exchange properties that are specific to mailboxes, you need to use the IAdmExchangeMailboxParameters interface. To access properties specific to mail-enabled contacts and distribution lists, use IAdmExchangeMailContactParameters and IAdmExchangeMailGroupParameters interfaces correspondingly.
The following code sample uses the IAdmExchangeMailboxParameters interface to get the name of the database a mailbox belongs to.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to user object $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Get the mailbox database name $mailboxProps = $user.GetMailParameters() $mailboxDB = $mailboxProps.StorageDatabase Write-Host "Mailbox database:" $mailboxDB
- C#
-
using System; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user object IADs user = (IADs)service.OpenObject( "Adaxes://CN=John Smith,CN=Users,DC=company,DC=com", null, null, 0); // Get the mailbox database name IAdmExchangeMailParametersOps exchangeOps = (IAdmExchangeMailParametersOps)user; IAdmExchangeMailboxParameters mailboxProps = (IAdmExchangeMailboxParameters)exchangeOps.GetMailParameters(); string mailboxDB = mailboxProps.StorageDatabase; Console.WriteLine("Mailbox database: " + mailboxDB); } }
For information on how to access specific Exchange properties, see Accessing specific Exchange properties.
For more samples, see
- Retrieving mailbox properties
- Retrieving mail-enabled group properties
- Retrieving mail-enabled contact properties
Modifying Exchange properties
To modify Exchange properties of an object, first you need to bind to the directory object that represents the mailbox, contact, or distribution list that you want to modify. All user, group, and contact objects support the IAdmExchangeMailParametersOps interface. To update Exchange properties of the object, call the SetMailParameters
method of the interface.
The first parameter of the SetMailParameters
method represents the modifications to be made to the object. The type of the parameter is IAdmExchangeMailParameters. So, before calling the SetMailParameters
method, you need to create an instance of the IAdmExchangeMailParameters interface. Depending on whether you want to modify parameters of a mailbox, mail-enabled contact, or mail-enabled group, you need to use different classes to instantiate the interface. Apart from the IAdmExchangeMailParameters interface, which is common for all recipient types, each class supports additional interfaces that are specific to each recipient type.
The table below specifies which class must be used to update different recipient types, and which interfaces are supported by each class.
Recipient Type | Class | Interfaces |
---|---|---|
Mailbox | AdmExchangeMailboxParameters | IAdmExchangeMailParameters, IAdmExchangeMailboxParameters |
Mail-enabled contact | AdmExchangeMailContactParameters | IAdmExchangeMailParameters, IAdmExchangeMailContactParameters |
Mail-enabled group | AdmExchangeMailGroupParameters | IAdmExchangeMailParameters, IAdmExchangeMailGroupParameters |
The following code sample enables ActiveSync for a mailbox user.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to user object $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Create an instance of the AdmExchangeMailboxParameters class $mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters" # Enable the ActiveSync mailbox feature $activeSyncFeature = $mailboxParams.MailboxFeatures.Create( "ADM_EXCHANGE_MAILBOXFEATURETYPE_ACTIVESYNC") $activeSyncFeature.Enabled = $true $mailboxParams.MailboxFeatures.Add($activeSyncFeature) # Save the changes $user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
- C#
-
using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to user object IADs user = (IADs)service.OpenObject( "Adaxes://CN=John Smith,CN=Users,DC=company,DC=com", null, null, 0); // Create an instance of the AdmExchangeMailboxParameters class AdmExchangeMailboxParameters mailboxParams = new AdmExchangeMailboxParameters(); // Enable the ActiveSync mailbox feature IAdmExchangeMailboxFeature activeSyncFeature = mailboxParams.MailboxFeatures.Create( ADM_EXCHANGE_MAILBOXFEATURETYPE_ENUM.ADM_EXCHANGE_MAILBOXFEATURETYPE_ACTIVESYNC); activeSyncFeature.Enabled = true; mailboxParams.MailboxFeatures.Add(activeSyncFeature); // Save the changes IAdmExchangeMailParametersOps mailOps = (IAdmExchangeMailParametersOps)user; mailOps.SetMailParameters(mailboxParams, ADM_SET_EXCHANGE_PARAMS_FLAGS_ENUM.ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE); } }
The following code sample hides a distribution list from Exchange address lists.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to group object $groupDN = "CN=My Group,CN=Groups,DC=domain,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" # Hide from address lists $groupParams.HiddenFromExchangeAddressList = $true # Save the changes $group.SetMailParameters($groupParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
- C#
-
using Softerra.Adaxes.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to group object IADs group = (IADs)service.OpenObject( "Adaxes://CN=My Group,CN=Users,DC=company,DC=com", null, null, 0); // Create an instance of the AdmExchangeMailGroupParameters class AdmExchangeMailGroupParameters mailboxParams = new AdmExchangeMailGroupParameters(); // Hide from address lists mailboxParams.HiddenFromExchangeAddressList = true; // Save the changes IAdmExchangeMailParametersOps mailOps = (IAdmExchangeMailParametersOps)group; mailOps.SetMailParameters(mailboxParams, ADM_SET_EXCHANGE_PARAMS_FLAGS_ENUM.ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE); } }
The second parameter of the SetMailParameters
method indicates whether to resolve value references when applying changes. The type of the parameter is ADM_SET_EXCHANGE_PARAMS_FLAGS_ENUM. If you want to update Exchange properties using modification templates that contain value references, you need to set the parameter to ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES
.
The following code sample adds an SMTP email address to multiple mail-enabled contacts. The email address will be their Employee ID plus '@example.com'. The script will use the following email address template %employeeID%@example.com. Value reference %employeeID% contained in the template will be replaced with the value of the Employee ID property of each contact object.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # DNs of the contact objects to update $contactDNs = @( "CN=Contact 1,CN=Users,DC=company,DC=com", "CN=Contact 2,CN=Users,DC=company,DC=com", "CN=Contact 3,CN=Users,DC=company,DC=com") # Create an instance of the AdmExchangeMailContactParameters class $contactParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailContactParameters" # Add a new modification $emailAddresses = $contactParams.EmailAddresses $emailAddresses.OverrideOldValues = $false $newAddress = $emailAddresses.CreateAddress("ADM_EXCHANGE_ADDRTYPE_SMTP", $null) $newAddress.Address = "%employeeID%@example.com" $emailAddresses.Add("ADS_PROPERTY_APPEND", $newAddress) $contactParams.EmailAddresses = $emailAddresses # Apply changes foreach ($contactDN in $contactDNs) { $contact = $service.OpenObject("Adaxes://$contactDN", $null, $null, 0) $contact.SetMailParameters($contactParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES") }
- C#
-
using System; using Softerra.Adaxes.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Cache; using Softerra.Adaxes.Interop.Adsi.Exchange; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // DNs of the contact objects to update string[] contactDNs = new string[] { "CN=Contact 1,CN=Users,DC=company,DC=com", "CN=Contact 2,CN=Users,DC=company,DC=com", "CN=Contact 3,CN=Users,DC=company,DC=com" }; // Create an instance of the AdmExchangeMailContactParameters class AdmExchangeMailContactParameters contactParams = new AdmExchangeMailContactParameters(); // Add a new modification IAdmExchangeProxyAddressModificationCollection emailAddresses = contactParams.EmailAddresses; emailAddresses.OverrideOldValues = false; IAdmExchangeProxyAddress newAddress = emailAddresses.CreateAddress( ADM_EXCHANGE_ADDRTYPE_ENUM.ADM_EXCHANGE_ADDRTYPE_SMTP, null); newAddress.Address = "%employeeID%@example.com"; emailAddresses.Add(ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND, newAddress); contactParams.EmailAddresses = emailAddresses; // Apply changes foreach (string contactDN in contactDNs) { IADs contact = (IADs)service.OpenObject("Adaxes://" + contactDN, null, null, 0); IAdmExchangeMailParametersOps contactOps = (IAdmExchangeMailParametersOps)contact; contactOps.SetMailParameters(contactParams, ADM_SET_EXCHANGE_PARAMS_FLAGS_ENUM. ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES); } } }
For more samples, see
- Modifying mailbox properties
- Modifying mail-enabled group properties
- Modifying mail-enabled contact properties
Accessing specific Exchange properties
The following tables show how to access specific Exchange properties using interfaces provided by Adaxes ADSI API.
General
Property |
Type |
API |
---|---|---|
Alias | string | IAdmExchangeMailParameters::Alias |
Display name | string | IAdmExchangeMailParameters::SimpleDisplayName |
Hide from address lists | bool | IAdmExchangeMailParameters::HiddenFromExchangeAddressList |
Custom attributes | IAdmExchangeCustomAttributes | IAdmExchangeMailParameters::CustomAttributes |
Mailbox database | string | IAdmExchangeMailboxParameters::StorageDatabase |
Archive database | string | IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_ARCHIVE").DatabaseName |
User MAPI rich text format | ADM_EXCHANGE_USEMAPIRICHTEXTFORMATTYPE_ENUM | IAdmExchangeMailContactParameters::UseMapiRichTextFormat |
Expansion server | IAdmObjectReference | IAdmExchangeMailGroupParameters::ExpansionServer |
Send out-of-office message to originator | bool | IAdmExchangeMailGroupParameters::SendOofMessageToOriginator |
Send delivery reports to group manager | bool | IAdmExchangeMailGroupParameters::ReportToManager |
Send delivery reports to message originator | bool | IAdmExchangeMailGroupParameters::ReportToOriginator |
Mailbox usage
Property | Type | API |
---|---|---|
Mailbox size | IAdmByteQuantifiedSize | IAdmExchangeMailboxParameters::UsageInfo.Size |
Total items | int | IAdmExchangeMailboxParameters::UsageInfo.TotalItemCount |
Last logon date | DateTime | IAdmExchangeMailboxParameters::UsageInfo.LastLogonDate |
Logged on by | string | IAdmExchangeMailboxParameters::UsageInfo.LastLogonUserName |
Storage quotas | IAdmExchangeStorageQuotas | IAdmExchangeMailboxParameters::StorageQuotas |
E-mail address
Property |
Type |
API |
---|---|---|
E-mail addresses | IAdmExchangeProxyAddressModificationCollection | IAdmExchangeMailParameters::EmailAddresses |
Automatically update e-mail addresses based on e-mail policy | bool | IAdmExchangeMailParameters::EmailAddressPolicyEnabled |
Mailbox policies
Property | Type | API |
---|---|---|
Sharing policy | IAdmObjectReference | IAdmExchangeMailboxParameters::IAdmObjectReference |
Role Assignment policy | IAdmObjectReference | IAdmExchangeMailboxParameters::RoleAssignmentPolicy |
Retention policy | IAdmObjectReference | IAdmExchangeMailboxParameters::RetentionPolicy |
Address Book policy | IAdmObjectReference | IAdmExchangeMailboxParameters::AddressBookPolicy |
Managed Folder policy | IAdmObjectReference | IAdmExchangeMailboxParameters::ManagedFolderMailboxPolicy |
Mailbox features
Property |
Type |
API |
---|---|---|
Outlook Web App | IAdmExchangeMailboxFeature, IAdmExchangeMailboxOwaFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_OWA") |
ActiveSync | IAdmExchangeMailboxFeature, IAdmExchangeMailboxActiveSyncFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_ACTIVESYNC") |
Unified Messaging | IAdmExchangeMailboxFeature, IAdmExchangeMailboxUnifiedMessagingFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_UNIFIEDMESSAGING") |
MAPI | IAdmExchangeMailboxFeature | IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_MAPI") |
POP3 | IAdmExchangeMailboxFeature, IAdmExchangeMailboxProtocolFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_POP3") |
IMAP | IAdmExchangeMailboxFeature, IAdmExchangeMailboxProtocolFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_IMAP") |
Archiving | IAdmExchangeMailboxFeature, IAdmExchangeMailboxArchiveFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_ARCHIVE") |
Retention Hold | IAdmExchangeMailboxFeature, IAdmExchangeMailboxRetentionHoldFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_RETENTIONHOLD") |
Litigation Hold | IAdmExchangeMailboxFeature, IAdmExchangeMailboxLitigationHoldFeature |
IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_LITIGATIONHOLD") |
Outlook Mobile Access (2003 only) | IAdmExchangeMailboxFeature | IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_OMA") |
User Initiated Synchronization (2003 only) | IAdmExchangeMailboxFeature | IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_UIS") |
Up-to-date Notifications (2003 only) | IAdmExchangeMailboxFeature | IAdmExchangeMailboxParameters::MailboxFeatures.GetItemByType ("ADM_EXCHANGE_MAILBOXFEATURETYPE_UDN") |
Mail flow
Property | Type | API |
---|---|---|
Delivery Options | IAdmExchangeDeliveryOptions | IAdmExchangeMailParameters::MailFlowSettings.DeliveryOptions |
Message Size Restrictions | IAdmExchangeMessageSizeRestrictions | IAdmExchangeMailParameters::MailFlowSettings.MessageSizeRestrictions |
Message Delivery Restrictions | IAdmExchangeMessageDeliveryRestrictions | IAdmExchangeMailParameters::MailFlowSettings.MessageDeliveryRestrictions |
Delivery Management (Groups) | IAdmExchangeMessageDeliveryRestrictions | IAdmExchangeMailParameters::MailFlowSettings.MessageDeliveryRestrictions |
Message Approval (Groups) | IAdmExchangeMessageModeration | IAdmExchangeMailParameters::MailFlowSettings.MessageModeration |
Delegation
Property |
Type |
API |
---|---|---|
Send As | IAdmObjectReferenceModificationCollection | IAdmExchangeMailParameters::SendAs |
Send on Behalf Of | IAdmObjectReferenceModificationCollection | IAdmExchangeMailParameters::GrantSendOnBehalfTo |
Full Access | IAdmObjectReference[] | IAdmExchangeMailboxParameters::MailboxRights.GetTrusteesGrantedRights ("ADM_EXCHANGE_MAILBOX_RIGHTS_FULL_ACCESS") |
Mailbox Rights | IAdmExchangeMailboxRights | IAdmExchangeMailboxParameters::MailboxRights |
Miscellaneous
Property | Type | API |
---|---|---|
MailTip | string | IAdmExchangeMailParameters::MailTip |
Automatic Replies (OOF) | IAdmExchangeMailboxAutoReplyConfiguration | IAdmExchangeMailboxParameters::AutoReplyConfiguration |
Calendar Settings | IAdmExchangeMailboxCalendarSettings | IAdmExchangeMailboxParameters::CalendarSettings |