This post is much less of a detailed how-to but rather some useful links. We were tasked with the job of sync’ing about 1,000 MS Exchange mailboxes to a Dovecot server. This needed to be done via an administrator account on the Exchange end as individual user passwords were not available.
The tool of choice for this is imapsync. Unfortunately, there is not a single formula that will work for all as it can depend on the Exchange configuration and version as well as the use of domains on the Exchange and ActiveDirectory servers.
To help understand the various combinations of logins for Exchange, I found the following invaluable: Understanding login strings with POP3/IMAP.
Also invaluable is the imapsync FAQ – just search for mentions of Exchange.
In the end, the following worked for me (but your mileage will most definitely vary!):
./imapsync --host1 exchange-server
--user1 'domain/adminuser/user' --password1 'admin-password'
--host2 dovecot-server --user2 email@example.com
One key element here is that when logging into Exchange as an individual user I had to use
--authmech1 NTLM but if you use this auth method with the above user string, you will always end up logging into the admin’s mailbox, not the user’s. That, at least, was my experience.