Retrieving CN from AD/Exchange

Posted on 2009-04-23
Medium Priority
Last Modified: 2012-05-06
Next week we are migrating from Small Business Server 2003 to Essential Business Server. Therefor we have to move from exchange 2003 to 2007.

I'm trying to automate Exmerge so that I have a backup PST file of our 60 mailboxes in case things go wrong. However to automate Exmerge I need to put the below text in a file called Mailboxes.txt for each user :


The problem is I don't know what the exchange username (DN) is for each user (vincent in the above example). I'd like to list all these names for every user in 1 operation. So far I tried LDP.exe and ADSI edit but with no luck.
Question by:vinden
  • 2
LVL 15

Accepted Solution

abhaigh earned 375 total points
ID: 24216365
what you are wanting is the LegacyExchangeDN

you can extract them via csvde in one shot with

csvde -f mailboxes.csv -r "(& (objectClass=user) (legacyExchangeDN=*))"

Author Comment

ID: 24222776
Thanks very much. I'm gonna accept that as an answer.

one last thing though :

Csvde now gives me lots of data per user. It gives me multiple CN's per user for instance. I'm still unsure which CN corresponds to the CN that I need to automate mailboxes with exmerge ?

For some users what exmerge needs is firstname only, for others it's firstname.lastname or fistname lastname and so on.

Exmerge needs this in mailboxes.txt :


CSVDE gives me this for each user :

CN=Vincent mylastnamehere,CN=Users,DC=mydomainhere,DC=local,user,Vincent mylastnamehere,,"CN=Vincent mylastnamehere,CN=Users,DC=mydomainhere,DC=local",4,20060321123146.0Z,20080829092327.0Z,Vincent mylastnamehere,847582,"CN=ISO,CN=Users,DC=mydomainhere,DC=local;CN=Usage Report Users,OU=Security Groups,OU=MyBusiness,DC=mydomainhere,DC=local;CN=allen,CN=Users,DC=mydomainhere,DC=local;CN=Domain Admins,CN=Users,DC=mydomainhere,DC=local",1732490,"CN=Microsoft MTA,CN=SERVER1,CN=Servers,CN=first administrative group,CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainhere,DC=local",smtp vd@mydomainhere.be;smtp vincent@mydomainhere.be;SMTP vincent.mylastnamehere@mydomainhere.be;X400 c=US\;a= \;p=First Organizati\;o=Exchange\;s=mylastnamehere\;g=Vincent\;,5717D53E-DD6D-4d1e-8A1F-C7BE620F65AA L,"CN=Mailbox Store (SERVER1),CN=First Storage Group,CN=InformationStore,CN=SERVER1,CN=Servers,CN=first administrative group,CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainhere,DC=local",,TRUE,vincent,X'494d415034c2a731c2a731c2a734c2a749534f2d383835392d31c2a730c2a731c2a730c2a730';X'504f5033c2a731c2a731c2a734c2a749534f2d383835392d31c2a730c2a7c2a7c2a7';X'48545450c2a731c2a731c2a7c2a7c2a7c2a7c2a7c2a7',Vincent mylastnamehere,X'f21c365cd95b0f4fb7a1ce2c989a6f5c',66048,0,0,0,128838172887343750,0,128850264985522250,ADMIN.bat,128309450578775168,513,,X'010500000000000515000000d94d6c95593b656dcdf819e121050000',1,9223372036854775807,1831,vinden,805306368,"CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainhere,DC=local;CN=All Users,CN=All Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainhere,DC=local",/o=First Organization/ou=first administrative group/cn=Recipients/cn=vincent,,"CN=Person,CN=Schema,CN=Configuration,DC=mydomainhere,DC=local",,,,c=US\;a= \;p=First Organizati\;o=Exchange\;s=mylastnamehere\;g=Vincent\;,vincent.mylastnamehere@mydomainhere.be,/o=First Organization/ou=first administrative group/cn=Configuration/cn=Servers/cn=SERVER1,51,X'01000480780000009400000000000000140000000400640001000000000214000300020001010000000000050a00000000000000520031003a003300320036003800000000010000000100000100000020000000000000000000000000000000000000000000000000000000000000000000000000000000010500000000000515000000d94d6c95593b656dcdf819e1f4010000010500000000000515000000d94d6c95593b656dcdf819e1f4010000',0,X'a57fb9bdc2fd3b41813760875ae0d881',"{C2253865-8EA6-4E80-99B5-16829D41FB50},{26491CFC-9E50-4857-861B-0CB8DF22B5D7}",mylastnamehere,Vincent,vinden@mydomainhere.local,,,,,,,FALSE,,,,,,,,,,,,,,,,,,      
LVL 15

Assisted Solution

abhaigh earned 375 total points
ID: 24222799
the LegacyExchangeDN is what you are after

this "/o=First Organization/ou=first administrative group/cn=Recipients/cn=vincent" is the LegacyExchangeDN in the example cited above

open the output in Excel and delete all unneeded columns


Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes Top 9 Exchange troubleshooting utilities that every Exchange Administrator should know. Most of the utilities are available free of cost. List of tools that I am going to explain in this article are:   Microsoft Remote Con…
There are literally thousands of Exchange recovery applications out there. So how do you end up picking one that’s ideal for your business & purpose? By carefully scouting the product’s features, the benefits it offers you, & reading ample reviews f…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question