Exchange 2003 2007 

Exchange Articles, News and Discussions
Welcome to Exchange 2003 2007  Sign in | Join | Help
in Search

Using CSVDE - A Real World Example


“Using CSVDE – A real world example” is the second of five follow up posts, from my original post “Top 5 tools an Exchange Administrator should not be without!”  in this post as promised I will give you a real world example on the use of the tool.

CSVDE is primarily used for the bulk export and import of Active Directory objects. As you would have properly guessed CSVDE exports and imports objects into and out via a CSV file. A benefit of using CSVDE is that exports can be opened in a spreadsheet such as Excel for manipulation.

You may have noted that CSVDE has a cousin, called LDIFDE, unlike CSVDE, LDIFDE  is primarily used to modify or delete Active Directory Objects, the other main difference is that LDIFDE uses the LDIF file format for the export and import of objects. Both CSVDE and LDIFDE ship with Windows Server 2003.

Before I begin my example I have copied from the command line a subset of CSVDE help, (CSVDE /?)

General Parameters
-i                Turn on Import Mode (The default is Export)
-f filename       Input or Output filename
-s servername    The server to bind to (Default to DC of computer's domain)
-v                Turn on Verbose Mode
-c FromDN ToDN   Replace occurences of FromDN to ToDN
-j path           Log File Location
-t port           Port Number (default = 389)
-u                Use Unicode format
-?                Help

Export Specific
-d RootDN        The root of the LDAP search (Default to Naming Context)
-r Filter         LDAP search filter (Default to "(objectClass=*)")
-p    SearchScope  Search Scope (Base/OneLevel/Subtree)
-l list           List of attributes (comma separated) to look for in an LDAP search
-o list           List of attributes (comma separated) to omit from input.
-g                Disable Paged Search.
-m                Enable the SAM logic on export.
-n                Do not export binary values

Import

-k                The import will go on ignoring 'Constraint Violation' and 'Object Already Exists' errors
 
Authentication

-a UserDN [Password | *]              Simple authentication
-b UserName Domain [Password | *]    SSPI bind method

Note: When performing operations with CSVDE, and you do not use the above authentication parameters, operations will be performed with the credentials of the account currently logged in using the SSPI bind method.

Well on to business, today I will show you how to export a CSV file/list of distribution groups along with each group’s members.

To perform this query we need to create an LDAP query so that instead of retrieving all objects from Active Directory we only retrieve the groups we are interested in. I can tell you we will need to search for objects with an objectCategory of group and an objectClass of group. You might then say there are two different types of groups, Security, and Distribution. but I only want a list of distribution groups. To do this you need to know the groupType attribute, now depending on the scope of the group (Domain Local, Global & Universal), Table 1 Below lists the groupType attributes for both Distribution and Security groups.

Group Scope

Distribution Group groupType

Security Group groupType

Domain Local

2

-2147483644

Global

4

-2147483646

Universal

8

-2147483640


Table 1 "The groupType attributes for various types of groups"


Note: If you include the query based distribution group there is actually three types of groups.

Below is the LDAP filter you will to export a list of Distribution Groups and their members for distribution groups with a Domain Local, Global or Universal Group Scope.

(&(objectCategory=Group)(objectClass=Group)(|(groupType=8)(groupType=4)(groupType=2)))

If you wanted to you could also include Query Based distribution groups, but this would not include members of the Query Based Distribution Groups (QBDG), this is because of the way this type of group works, it does not contain a multi valued member attribute of members, instead it uses an LDAP query to determine its members. The LDAP filter listed below includes QBDG

  (|(&(objectCategory=Group)(objectClass=Group)(|(groupType=8)(groupType=4)(groupType=2)))(objectCategory=ms-Exch-Dynamic-Distribution-List)(objectClass=msExchDynamicDistributionList))

Now to string the command together,

Go to Start | Run | Type cmd press Enter

In the cmd window type or copy/paste the following command and press enter:
 
csvde -f c:\temp\DistributionLists.csv -p subtree -l cn,mail,member  -r "(|(&(objectCategory=Group)(objectClass=Group)(|(groupType=8)(groupType=4)(groupType=2)))(objectCategory=ms-Exch-Dynamic-Distribution-List)(objectClass=msExchDynamicDistributionList))" -j c:\temp

You will now find a csv file in c:\temp named DistributionLists.csv which contains the list of exported group and members.

If you are not logged onto your server with an account that has rights to the domain from which you want to export distribution lists from you will need to use the –b parameter.

If you need to run this command against a specific server you should specify the –s parameter.

Figure 1 below is what you should see if the command has ran successfully.


Figure 1 “CSVDE.exe has successfully ran”

From here you can open the csv file in excel so that the data can formatted in an a more easily viewable format

Published Thursday, July 14, 2005 12:47 AM by Ben Hoffman

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

subject: exchange said:

July 15, 2005 6:41 PM
 

subject: exchange said:

July 15, 2005 11:46 PM
 

Vamsi said:

hi,

I want to know how to Install CSVDE on an XP client machine and run it from the XP machine.

Please explain.

vamsikris123@yahoo.com

thanks
Vamsi
February 27, 2006 6:56 AM
 

monkey said:

Vamsi, you should lookup the DSadd, DSquery, etc commands for xp and later. If you want to run it from a client, then you need to install exchange server onto the machine.

May 5, 2007 1:08 AM
 

JPP said:

It works but in the csv file i don't see the member's names.  I only see a lot of numbers like this :

DN,cn,member,mail

"CN=Legume,OU=ListServ,DC=craaq,DC=qc,DC=ca",Legume,X'434e3d4d617269652d506965727265204772696d6172642c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d47656e657669c3a87665204c656761756c742c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d416e6e6520446573726f63686572732c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d4576656c696e6520466f72746965722c434e3d55736572732c44433d63726161712c44433d71632c44433d6361';X'434e3d4b6172696e65204265726765726f6e2c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d53796c766965204269656e76656e75652c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d52656d7920466f7274696e2c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d4a6f73c3a96520426f6e6e6576696c6c652c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d56696e63656e74205068696c696f6e2c4f553d436f6e7461637443524141512c44433d63726161712c44433d71632c44433d6361';X'434e3d537

June 2, 2007 12:10 AM
 

WindowsIS said:

DHCP in Windows Server is one of those little thought about services that do not get much attention unless you are setting up a new DHCP server, configuring a DHCP scope, or migrating to another physical server. So just how do you go about migrating a

June 12, 2007 12:11 PM
 

krishna said:

how to get members sAMAccountName .

we get mmbers DN but i want sAMAccountName .

can any one tell me how to do that

November 26, 2007 3:17 PM
 

WindowsIS said:

Windows Server 2008 Active Directory Domain Services ADDS Setup walkthrough: The release of Windows Server 2008 has brought about some new options when promoting a server to be a Domain Controller. This article will step you though these advanced options

March 18, 2008 8:19 AM
 

W2K8 and CSVDE | keyongtech said:

January 18, 2009 11:36 AM
 

List of users and their Distribution Groups | keyongtech said:

January 29, 2009 10:09 AM
 

Anhnn said:

thanks :P

March 10, 2009 3:38 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

About ExchangeIS


<script type="text/javascript" src="http://technorati.com/embed/zmyi3iatks.js"> </script>

ExchangeIS Privacy Policy Powered by Community Server (Commercial Edition), by Telligent Systems