CSVDE and LDIFDE

Introduction to CSVDE and LDIFDE

The main purpose of this page is to explain the differences between Microsoft’s CSVDE and LDIFDE. If you can provide data about your users, computers or contacts in a text file, then CSVDE or LDIFDE can create the corresponding account in Windows Server 2003/8 Active Directory.

The second purpose of this page is to act as a mini sitemap to guide you to my tutorials for importing and export with CSVDE and LDIFDE.

However, before I go into detail, here are three classic uses of the these Windows Server 2003 and 2008 commands;

  • Bulk import of NEW user accounts. (CSVDE)
  • Creation of computer accounts.
  • Modification of EXISTING Active Directory accounts. (LDIFDE)

CSVDE

Comma Separated Value Data Exchange.
Uses a comma-delimited file with LDAP fields in the first row, followed by rows of account data.  Excel is a good vehicle to hold and manipulate CSVDE files.

When importing accounts, always try CSVDE first because the syntax is so much easier than LDIFDE. 

Another advantage of Microsoft’s CSVDE is it understands and thrives on CSV files.  This means that you can manipulate the data in a spreadsheet before you import data into Active Directory.

Next Step

CSVDE – Export.  The best way to get started.

CSVDE – Import.  How to add user accounts to Active Directory.

LDIFDE

Lightweight Data Interchange Format, Data Exchange.
Has line-separated values between each record.  The data is not suitable for spreadsheets.

My advice is use Microsoft’s LDIFDE when ever CSVDE is not up to the job, for example, if you need to import users with passwords CSVDE will not work.

LDIFDE has more powerful verbs, for instance CSVDE can only add users, whereas LDIFDE can modify or even delete their accounts.

Next Step

LDIFDE – Export.  An easy way to get started.

LDIFDE – Import.  How to add, modify or delete user accounts.

 

 See More on CSVDE and LDIFDE

Alternatives to CSVDE and LDIFDE

Having given an honest and fair account of both CSVDE and LDIFDE, I urge you also to consider PowerShell or VBScript for creating Active Directory accounts. 

PowerShell and Active Directory

Example Simple Script to Echo the Active Directory Domain

# PowerShell Connects to Active Directory
# Connect to hard-coded root
# Author: Guy Thomas
# Version 1.3 Sept 2007 tested on PowerShell v 1.0 and RC2

$Dom = ‘LDAP://DC=cp;DC=mosel’
$Root = New-Object DirectoryServices.DirectoryEntry $Dom
Write-host "PowerShell connects to domain: $Dom"

Learning Points

Note 1:  ‘LDAP://DC=cp;DC=mosel’.  Rather than using the traditional .local namespace for non-internet domains, I prefer .mosel merely because it happens to be the road where I live!  Naturally you changed the value for this $Dom variable in your live script?  Didn’t you?

Note 2:  New-Object is such an insignificant command, yet it is vital for creating objects, which we can use for connecting connect to Active Directory.

Note 3:  DirectoryServices.DirectoryEntry is one of the key commands to connect to Active Directory.  I think of this as a pipeline to the root of my domain’s namespace.  See more on PowerShell and Active Directory

Guy Recommends:  SolarWinds’ Free Bulk Import ToolFree Download Solarwinds Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD’s attributes, click and import the users.

Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.

If you need more comprehensive software, download a free trial of SAM (Server & Application Monitor)

VBScript

While VBScript is not as quick and is more difficult to learn, in the long term

VBScript Example – Script to Create a User in Active Directory

On this page we concentrate on the essential VBscript commands necessary to build a User account in Active Directory Users and Computers.  For example, GetObject("LDAP://rootDSE") and .Create("User").  Even though I am experienced at creating VBScripts, I still run manually through creating the object in Active Directory Users and Computers, the menus actions help me to rehearse the stages in my scripts.

Prerequisites

I recommend that you logon at a Windows Server domain controller.  If you are a long way from the server, Remote Desktop would be a suitable alternative.  If that is not possible, you could get these scripts to work from an XP machine as a non-administrator.  However, why introduce extra complications?  Especially at the beginning, you want easy success, with fewest obstacles.

Instructions for Creating a User Account in Active Directory

  1. You should run this VBScript on a Windows Active Directory domain.
  2. Copy and paste the example script below into notepad or a VBScript editor.
  3. Decide whether to change the value for strUser.  DomGuy2 is not a particularly attractive name.
  4. Save the file with a .vbs extension, for example: Users .vbs.
  5. Double click Users .vbs and check the Users container for strUser.

Script to Create a User in a Named OU (Organizational Unit)

 

‘ Users .vbs
‘ Sample VBScript to create a User in Users .
‘ Author Guy Thomas http://Computerperformance.co.uk/
‘ Version 1.3 – September 2010
‘ ——————————————————‘
Option Explicit
Dim strUser
Dim objRootLDAP, objContainer, objNewUser
strUser = "DomGuy2"

‘ Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Users," & _
objRootLDAP.Get("defaultNamingContext"))

‘ Build the actual User.
Set objNewUser = objContainer.Create("User", "cn=" & strUser)
objNewUser.Put "sAMAccountName", strUser
objNewUser.SetInfo

WScript.Quit

‘ End of free sample Create Users VBScript.

VBScript Tutorial – Learning Points

Note 1:  The first 10 lines explain the purpose of the script and declare the variables.

Note 2:  The simple, but clever command, which allows the script to work with any domain is: GetObject("LDAP://rootDSE").  Crucial, this statement binds WSH / VBScript to Active directory.  The next line puts the focus on the Users container, as that is where the user will be born.  Incidentally, the correct syntax is cn=users, whereas OUs that you create need the OU= prefix, for example OU=Accounts,.

 VBScript – See more here

 See More on CSVDE and LDIFDE