Welcome to IT Free Training. In this video I will look at automating the importing and
exporting of users in Active Directory. The video will look at two command line tools
provided by Microsoft called CSVDE and LDIFDE. If you have a scenario in your workplace where
you need to create a large number of users very quickly these tools become invaluable.
For example, if you work in an educational institution there may be a need to create
a large number of new users at enrolment time. In the workplace, you may need to migrate
a large number of users from one system to another system. Using automate tools like
the ones described in this video makes the process a lot faster.
I will begin by starting with CSVDE followed by LDIFDE. The fundamental difference between
the two tools is the format the tools used to import and export data. CSVDE uses comma-delimited
files, which are compatible with software like excel. LDIFDE uses the Lightweight Directory
Access Protocol Data Interchange Format otherwise known as LDif. Using the LDif format, you
can export Active Directory users and import them into other non-Active Directory based
systems. To start with, I will look at CSVDE tool.
First of all, I will open a command prompt from the Start menu. The CSVDE tool has quite
a few options, so I will only go through the most commonly used options. For a complete
list of the options see the link in the description for this video.
I will now perform an export to give you a better understanding of the CSV format the
tool uses. Once the data has been exported, the CSV file can be opened in excel or notepad.
To perform the export, this is done with the –f parameter followed by the filename, in
this case I will call it OutputAD.CSV. There are not too many objects in this domain
so the process will not take too long. Once complete, I can now open Windows Explorer
and see the export file. Since I have Excel installed on this computer, I can double click
the file to open it in Excel. Here you can see all the data that was exported.
If I scroll to the right you will notice that there are a lot of columns of data. If you
are importing this data on anther system you may be able to import the data file as is
without any modification. CSVDE can also be used to import data. If
I scroll back to the start I will find many of the columns are not required when creating
new accounts. Therefore, I will delete the extra columns and the unwanted data from the
file. When creating a new account, in many cases you will just want basic information
such as the username, first and last name of the new user.
Once I have removed the extra data and columns, I will be left with six columns. This provides
the basic attributes for the user accounts that I want to create. I can now enter in
the details for 3 users accounts that I want to create. Most attributes are fairly simple
to understand. Object Class is the type of object you want to create, in this case a
user. The Sam Account Name is the username used with operating systems before Windows
2000. SN is for the surname, given name the first name and the User Principal Name the
Windows logon name in email style format. The first column DN, contains the distinguished
name for the object which allows you to specify the domain and Organizational unit the object
is to be created in. Once you are happy with the data in the Excel spread sheet, select
the option, save as. In this case I will save the file as InputAD so the original OutputAD
file is preserved. When saving the file, you should ensure that the type is CSV comma delimited.
If you save the file as anther format, CSVDE will not be able to read the file.
Excel will prompt you telling you that if you save the file in this format you will
lose any features that are not supported in this file format. For our requirements this
is fine so I will press yes. If I now go back to Windows Explorer, if I
right click on the file and select open with, I can select notepad to open the file. Notice
that the file is a text base file so I could have created the file with notepad or this
file could have been exported using 3rd party software or scripts.
If I now go back to the command prompt, I can import this file by running CSVDE –i
for import and -f followed by the filename. Once the command has run, notice that I get
a message saying that there was an error. The problem was that one of the users in the
file already exists. When CSVDE encounters an error it will exit. To get around this
you can add the –k parameter. This will tell CSVDE to ignore errors and continue processing.
When I run the command again with the –k parameter, notice that the error indicating
the user already exists will be reported again. This time the command will process all the
users in the file and not stop when it encounters an error.
This covers how to use the CSVDE tool. The next tool that I will look at is LDIFDE. Although
LDIFDE exports data in a different format, the parameters for CSVDE and LDIFDE are the
same. If I open the command prompt again, as with
the last command, I will need to run LDIFDE with the parameter –f followed by the filename.
This will export all the objects from Active Directory into a file in LDif format.
Now that the data has been exported, I will go back to Windows explorer and open the file.
When asked, I will select notepad to open the file when prompted. Notice the file is
text based like the CSV file, however the format of the file is very different. You
can see at the top the attribute DN. Any 3rd party directory system that supports this
format will be able to read this file and make use of the data.
To import the file with LDIFDE, just like CSVDE you use the parameter –i. Normally
you would not import the same data that you just exported in the same domain, but for
the purpose of the demonstration this is how you would import a LDif file. Just like with
the CSVDE command, you can add the –k parameter and this will ignore any errors that it finds
and continue processing to the end of the file.
This covers the CSVDE and LDIFDE tool. You can see that these tools can be used to automate
the creation and migration of Active Directory objects in Windows and in other systems.
This video was provided by IT Free Training and is only one video in the free Active Directory
course. Please see our website or YouTube channel for more free videos and courses.
Thanks for watching.