Retrieving CN from AD/Exchange

Posted on 2009-04-23
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
    LVL 15

    Accepted Solution

    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=*))"
    LVL 3

    Author Comment

    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;smtp;SMTP;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\;,,/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

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do email signature updates give you a headache?

    Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

    Suggested Solutions

    Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
    In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now