4.27. Importing Objects Using a CSV File
Problem
You want to import objects into Active Directory using a CSV file.
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:
DN,objectClass,cn,sn,userAccountControl,sAMAccountName,userPrincipalName
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,jim@rallencorp.com "cn=john,cn=users,dc=rallencorp,dc=com",user,,512,john,john@rallencorp.com
Once you’ve created the CSV file, you just need to
run cvsde command to import the new objects.
> csvde -i -f input.csv
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 ...