Exchangetoox

From Open-Xchange
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Introduction

The document describes a way how mailboxes can be migrated from MS Exchange™ to a cyrus IMAP server using imapsync without the need to know the user passwords.

Requirements

  1. A cyrus IMAP server and an admin account
    the admin accounts for cyrus are defined in the admins: parameter of the /etc/imapd.conf configuration file. In the examples, the admin user name is cyrus with password cpass.
  2. Microsoft Exchange 2003™
    other Microsoft Exchange™ versions might work, too. This howto was written for the 2003 version.
  3. Postmaster account for MS Exchange™
    The Exchange™ account for migration needs to have the permission to access all mailboxes on the MS Exchange™ server. In the examples the user name is migration with password mpass. The user can be created following these steps:
    1. Create a new DWORD in HKEY_Current_User\Software\ Microsoft\Exchange\ExAdmin with the name ShowSecurityPage and set this to 1.
    2. Open the Active Directory User and Computer console and create a new user with the name migration, password mpass and Exchange attributes.
    3. Reopen the MS Exchange™ System Manager and give that new user full access to the entire mail organization (right click on the uppermost entry naming your organization -> properties -> security -> add)

Testing the admin users

Those example IMAP logins describe a telnet session where a succesful IMAP connection is created and closed (cyrus is running on localhost and the Exchange server on 10.20.30.170)

Test if the cyrus admin can access the server

[]# telnet localhost imap
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS AUTH=LOGIN AUTH=PLAIN SASL-IR] servera Cyrus IMAP4 v2.3.7-Invoca-RPM-OX-2.3.7-3.OX server ready
. login cyrus cpass
. OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE LISTEXT LIST-SUBSCRIBED X-NETSCAPE URLAUTH] User logged in
. logout
* BYE LOGOUT received
. OK Completed
Connection closed by foreign host.
[]#

Test if the migration user can log in to own mailbox

 []# telnet 10.20.30.170 imap
Trying 10.20.30.170...
Connected to mastercane.open-xchange.com (10.20.30.170).
Escape character is '^]'.
* OK Der Microsoft Exchange Server 2003 IMAP4rev1-Server, Version 6.5.6944.0 (win2003.perf.open-xchange.local), steht zur Verf�gung.
. login migration mpass
. OK LOGIN completed.
. logout
* BYE Der Microsoft Exchange Server 2003 IMAP4rev1-Server, Version 6.5.6944.0, meldet sich ab.
. OK LOGOUT completed.
Connection closed by foreign host.
[]#

Test if the migration user can log in for user test in domain

[]# telnet 10.20.30.170 imap
Trying 10.20.30.170...
Connected to mastercane.open-xchange.com (10.20.30.170).
Escape character is '^]'.
* OK Der Microsoft Exchange Server 2003 IMAP4rev1-Server, Version 6.5.6944.0 (win2003.perf.open-xchange.local), steht zur Verf�gung.
. login domain/migration/test mpass
. OK LOGIN completed.
. logout
* BYE Der Microsoft Exchange Server 2003 IMAP4rev1-Server, Version 6.5.6944.0, meldet sich ab.
. OK LOGOUT completed.
Connection closed by foreign host.
[]#

Migrating a single user

Access to the MS Exchange™ mailbox is done via <domain>/migration/<user to migrate> and the password of the migration account. In cyrus the Data is stored as user with the credentials of the admin account. The imapsync command is as follows:

imapsync --host1 <ms exchange> --user1 <domain>/migration/<user to migrtate1> --password1 \
         mpass --host2 <cyrus server> --user2 <user to migrate2> --authuser2 cyrus \
         --password2 cpass --authmech2 PLAIN --prefix1 "INBOX." --regextrans2 \
         's/INBOX.INBOX/INBOX/'  --noauthmd5 --subscribe \
         --exclude "&ANY-ffentliche Ordner|Aufgaben|Journal|Kalender|Kontakte|Notizen" --dry
variable value
<ms exchange> hostname or ip of the Exchange server
<domain> Active directory domain name
<user to migrtate1> Exchange user to be migrated
<cyrus server> hostname or ip of the cyrus imap server
user to migrate2 target user name in the cyrus imap server
--exclude a list of system folders not to migrate

The above command does actually do a try run without migrating any data. This is because of the --dry option. It is needed to see what special folders are available that do not need to be migrated. These are the folders calendar,contacts,tasks,notices and shared folder. They differ from each other in the single languages. It is also save to check if the standard folders are the same on both sides (if not, that can be tuned with (multiple are possible) --regextrans2 and a regular expression that fixes that).

Removing the --dry option will actually migrate the user.

Then, the sync can run multiple times e. g., a comprehensive job can run to migrate the majority of the data and once again just before the user changes to the new server.

Bulk import of multiple users

Sample for importing OX users

This script basically lists all users from a Open-Xchange context and uses the user id as username for the imap servers to import all.

#!/bin/sh

#GLOBIGNORE='*'

# Target OX context id
CID=1

# cyrus settings
CYRHOST=localhost
CYRUSADM=cadm
CYRPWD=cpass

# exchange settings
MSHOST=10.20.30.170
MSDOM=domain
MSADM=madm
MSPASS=secret
SYSFOLD="&ANY-ffentliche Ordner|&ANY-ffentliche Ordner/Internet Newsgroups|Aufgaben|Journal|Kalender|Kontakte|Notizen|Calendar|Contacts|Notes|Tasks"


export PATH=$PATH:/opt/open-xchange/sbin/


for user in $(listuser -c $CID | grep -v ^Id | awk '{ print $2 }'); do

        imapsync --host1 "$MSHOST" \
                --user1 "${MSDOM}/${MSADM}/${user}" \
                --password1 "$MSPASS" \
                --host2 "$CYRHOST" \
                --user2 "$user" \
                --authuser2 "$CYRUSADM" \
                --password2 "$CYRPWD" \
                --authmech2 PLAIN \
                --prefix1 "INBOX." \
                --regextrans2 's/INBOX.INBOX/INBOX/' \
                --noauthmd5 \
                --subscribe \
                --exclude \""$SYSFOLD"\" \
                --dry

done