Skip to content

Creating mailboxes

The following code sample creates a mailbox for a user.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.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 the user
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Create mailbox
$user.CreateMailbox($alias, "Adaxes://$mailboxDatabaseDN")

See also