Recipe 4.27 Importing Objects Using a CSV File

4.27.1 Problem

You want to import objects into Active Directory using a CSV file.

4.27.2 Solution Using a command-line interface

To import objects using the csvde utility, you must first create a CSV file containing the objects to add. The first line of the file should contain a comma-separated list of attributes you want to set, with DN being the first attribute. Here is an example:


The rest of the lines should contain entries to add. If you want to leave one of the attributes unset, then leave the value blank (followed by a comma). Here is a sample CSV file that would add two user objects:

DN,objectClass,sn,userAccountControl,sAMAccountName,userPrincipalName "cn=jim,cn=users,dc=rallencorp,dc=com",user,Smith,512,jim, "cn=john,cn=users,dc=rallencorp,dc=com",user,,512,john,

Once you've created the CSV file, you just need to run cvsde command to import the new objects.

> csvde -i -f input.csv

4.27.3 Discussion

Note that each line of the CSV import file, except the header, should contain entries to add objects. You cannot modify attributes of an object or delete objects using csvde. If you have a spreadsheet containing objects you want to import, first save it as a CSV file and use csvde to import it. Using a command-line interface

To import with csvde, simply specify the -i switch to turn on import mode and -f <filename> for the file. It can also be beneficial to use the -v switch to turn on verbose mode to get more information in case of errors.

4.27.4 See Also

Recipe 4.26 for exporting objects in CSV format, and MS KB 327620 (HOW TO: Use Csvde to Import Contacts and User Objects into Active Directory)

Active Directory Cookbook
Active Directory Cookbook, 3rd Edition
ISBN: 0596521103
EAN: 2147483647
Year: 2006
Pages: 456

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: