For Exchange 2000 and Exchange 2003 prior Service Pack 1, the building of an URL suitable for WebDAV requests against a users mailbox is a rather complicated thing. A solution for this is descrbied under the section Solution.
From Exchange 2003 SP 1 onwards, you can just use his SMTP address to get access to his mailbox. For example, to access the mailbox of John Doe (email@example.com) you would use the url
To build the webaddress, you must do the following:
- If you only have a domain\username, not the distinguished name of the user, you must first get the latter one. See this aricle how to retrieve the name.
- Get the directory entry with the distinguished name of the user
- From that object, retrieve the property homemdb. This property contains the distinguished name of the mailbox store.
- Retrieve the directory entry of the mailbox store.
- From this object, retrieve the property named msExchOwningServer. This is the distinguished name of the Exchange server that hosts the mailbox.
- Get the root of the http virtual server on the exchange server. The distinguished name is CN=http, CN=Protocols, <distinguished name of the exchange server>.
- Search for all http virtual server (LDAP filter: (objectClass=protocolCfgHttpServer), Scope: OneLevel, retrieve these properties: msExchServerBindings, msExchDefaultDomain).
- From this list, retrieve the default SMTP server. It's the one without the attribute msExchDefaultDomain.
- Get the default SMTP domain of the organization:
- Open the node CN=Default Policy, CN=Recipient Policies, CN=<Name of your organization>, CN=Microsoft Exchange, CN=Services,<Distinguished name of the configuration naming context>.
- Retrieve the property gatewayProxy. This is a multi-valued property that contains the default addresses of the organization.
- Check each of the entries in that list. If it starts with SMTP:, you have found it.
- Get the property proxyAddresses from the directory object of the user. This is a multi-valued properties that contains all addresses that are assigned to the user. Each entry has the following consists of a protocol identifier and an address entry. For example:
If the protocol identifier is all uppercase, it is the default entry for that protocol.
- Iterate through the list of assigned addresses and search for the SMTP address which domain part matches with the default SMTP retrieved above.
- Select the correct HTTP Server:
- If you found an email address corresponding to the default SMTP policy, extract the alias from the found address. For the above example the alias would be john.doe. The correct HTTP server to use is the default HTTP Server
- If there is no smtp address matching the default policy, iterate through the list of proxy addresses again, and do the following, if it is an SMTP address:
Get the property msExchServerBindings from the selected HTTP server node. This entry has the following structure:
Extract the alias and the domain from the address.
Iterate through the list of virtual HTTP server and check the property msExchDefaultDomain of each entry. If it matches the domain of the users address domain, you have found the correct http server.
The first and the last part of the string can be empty, like in this example:
:80:Depending on the content of this field, you can now build the desired url:
- If the servername of the msExchServerBindings property is not empty, build the OWA url like this:
- If the servername is empty, but an ipaddress is present, build the OWA url like this:
- If both, the servername and the ipaddress fields are empty, get the ipaddress for the exchange server:
- From the node of the exchange server, retrieve the property networkaddress.
- Iterate through this property and retrieve the value which starts with ncacn_ip_tcp:.
- Now, build the url with the above scheme, using the just found ip address.