Thursday, February 26, 2009

Migrating Global Address List from Exchange 2003 to Exchange 2007 Cross-Forest

Following are the steps to migrate an Exchange 2003 Global Address List to an Exchange 2007 Organization Cross-forest. The important thing is that there is no physical connectivity between both the forests/organizations. These are 2 independent entities between which no Trust or Synchronization can be established.

Step 1: Use the CSVDE command to export the users or contacts into a .CSV file.

csvde -r "(objectClass=User)" -d "ou=testou,dc=ad,dc=testdomain,dc=co,dc=jp" -l displayName,mail,proxyAddresses,targetAddress,mailNickname -f c:\userlist.csv

Note – If you need to export contacts from Active Directory you need to change the objectClass=user to objectClass=Contacts.

All the attributes like

“displayName,mail,proxyAddresses,targetAddress,mailNickname” are necessary to export mail enabled users and contacts.

STEP 2: Take the userlist.csv file to the other Forest/Exchange Server.

STEP 3: Open the file in an Excel Sheet.

  • Insert a new column after the displayName. Name the column as objectClass. Enter the value into the column as User or Contact in front of each Object Exported

If you do not add “objectClass” as a column the CSVDE import command fails with the following error

"error reading attribute list"

  • Rename the column header Mail with targetAddress.

At this point we need to change the DN name to the one of your domain.

In our scenario the DN name was “dc=ad,dc=testdomain,dc=co,dc=jp” and we had to change it to “DN=newdomain,DN=com”. Use the replace all option in Excel to replace “dc=ad,dc=testdomain,dc=co,dc=jp” to “DN=newdomain,DN=com”.

We had the exported users in different OU’s.

Example

CN=User1,OU=testou,DC=newdomain,DC=com

CN=User2,OU=testou, DC=newdomain,DC=com

When you run the CSVDE command to import the userlist.csv file it fails with the error that it cannot find the OU’s in active directory.

We used the following Excel Formula to convert the entries without OU’s

=CONCATENATE(LEFT(A2,SEARCH("OU",A2,1)-1),RIGHT(A2,LEN(A2)-SEARCH("DC",A2,1)+1))

The above command changed the following

CN=User1,OU=testou, DC=newdomain,DC=com

TO

CN=User1, DC=newdomain,DC=com

NOTE – This would import all the entries under the domain name in Active Directory Users and Computers. You can then move the objects in OU’s as you require.

STEP 4: Run the following command to import the modified .CSV file in the command prompt

C:\> CSVDE –i –f <location of userlist.csv>

NOTE – Once you run this command you should ideally see all the objects in the GAL. But it does not do that in Exchange 2007. The reason being that the GAL in Exchange 2007 has different attributes.

STEP 5: Once you import the file into an Exchange 2007 Org.

Go to Exchange Management Console > Recipient Configuration > Mail Contact

You will see all the objects in there if you have imported them as contact objectClass. If you have imported them as users you see them under

Exchange Management Console > Recipient Configuration > Mailbox

You wont be able to see the contact/users in the GAL until you uncheck and check the “Automatically update e-mail addresses based on e-mail address policy”.

Make sure that you have an External E-mail Address for all the users/contacts. If not then you need to create a new Recipient Policy to set External E-mail Addresses for all of them and apply the policy.

You will have to make all the users mail enabled in order to show all the users/contacts in to the Global Address List.

The shell command to make the contacts mail enabled is ‘set-mailcontact’.

NOTE: In our case all the objects that were imported were contacts. Hence we used the ‘set-mailcontact’ shell cmdlet to mail enable the contacts.

Please refer to the following link for more information on the Exchange Management Shell cmdlets

http://technet.microsoft.com/en-us/library/aa995950.aspx

STEP 6: We need to write a script in order to make bulk contacts mail enabled ( In our scenario we have more that 5000 contacts to be mail enabled).

Following was the script written ‘addcontact.vbs’

========================================================

Set WShell = Wscript.CreateObject("Wscript.Shell")

set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = objFSO.Opentextfile("alias.txt",1)

do while objfile.AtEndOfStream = false

strline = objfile.Readline

if strline = "" then

'do nothing

else

wshell.run "powershell.exe" & " -PSConsoleFile" & " exshell.psc1" & " set-mailcontact" & " " & strline

wscript.sleep(10000)

'msgbox "powershell.exe" & " -PSConsoleFile" & " exshell.psc1" & " set-mailcontact" & " " & strline

End if

Loop

==========================================================

This should show all the contacts/users in the Global Address List now.


No comments: