Home > Windows Server Tips > Active Directory Administration > Active Directory tools ease import/export of data
Windows Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ACTIVE DIRECTORY ADMINISTRATION

Active Directory tools ease import/export of data


Gary Olsen, Contributor
07.18.2006
Rating: -2.64- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In a previous article on LDIFDE, Extracting AD info quickly and easily with LDIFDE, I explored using the LDIFDE.exe tool to export data. I covered an introduction to the tool itself, basic syntax as well as the fundamentals of using the LDAP search filter to narrow down the output.

In this article, I will discuss two additional features in this area: importing data and the use of CSVDE.exe, an additional utility with similar syntax as LDIFDE, allowing you to output data to or input data from a comma-separated file.

First, let's examine importing using LDIFDE. This can be done in the form of modifying already exported objects or by creating new ones. Objects can also be imported into other LDAP directory services; or objects that were exported from other services can be imported to AD with LDIFDE import. To import, you must use the –i option with the ldifde command, along with at least an input file name and the DC it is to connect to.

The following command imports the objects specified in the input file newusers.ldf on the server ATL-DC1: Modifying user attributes
Suppose the company had moved the engineering department to a new building on the other side of town, giving those users a new street address and postal code. We can script the change with LDIFDE by starting with a dump of the Engineering OU. The Address.ldf output file (partial list): Now we can modify the exported Address.ldf file with the needed corrections and import it back into the Engineering OU. Using the exported Address.ldf, you can see that some users didn't have any address attributes and some had their home address listed. By simply editing that .ldf file and inserting the attributes for city, state, street address and postal code, we can quickly import them into the Active Directory. The address.ldf file is modified to change the address to 123 Sycamore Court, Roswell, GA 3...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Microsoft Active Directory Tools and Troubleshooting
How to find and remove lingering objects in Active Directory
DNS troubleshooting best practices
Generating a DNS health check in Windows
Debugging Windows client logon delays: Narrowing the scope
Troubleshooting poor Windows logon performance in Active Directory environments
New Operations Manager 2007 feature allows for automated agent deployments
Taming the LSASS.exe process for Active Directory performance and security
Active Directory FAQs
Troubleshooting Active Directory database errors
Troubleshooting a cross-forest trust in Active Directory

Active Directory Administration
How to find and remove lingering objects in Active Directory
Utilizing Active Directory snapshots in Windows Server 2008
Creating Windows taskpad views for Active Directory management
When to add new domains to your Windows environment
Debugging Windows client logon delays: Narrowing the scope
Using Active Directory to manage Macs in a Windows environment
Troubleshooting poor Windows logon performance in Active Directory environments
Common Active Directory security oversights
Scripting domain controller installations: A must for Server Core
Taming the LSASS.exe process for Active Directory performance and security

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


0706 as follows: This import file has some interesting caveats that will drive you crazy until you figure them out. To save you some time, here they are:

  • If you are making changes to an existing object, use the Modify changetype. Note that Caroline Carter didn't have any address attributes -- but we used modify rather than add.
  • The syntax to replace an attribute is:
  • Replace:<attribute>
  • <attribute>:<new value>
    • You can specify multiple attribute changes, but each one must be separated with a line containing only a hyphen (-).
    • The first attribute replaced is not separated from the changetype line with a hyphen (-).
  • Before starting a new Object, separate previous commands with a line containing only a hyphen and a blank line.
The LDIFDE command to import these changes to the AD are: The results can be viewed in the Users and Computers snap-in as shown in Figure 1.

Figure 1. User Properties of user Caroline Carter show modified values for address fields.

[IMAGE]

Adding new users
You can add users by creating a text file in the following format. Note that the ObjectClass must be specified and there is a blank line delimiter between the object specifications (and just when you thought you had that stuff with the hyphens figured out): This file can be used to import the objects to the AD with this command: Note: Users imported with LDIFDE in this manner will be automatically disabled in Active Directory. Users can also be deleted by importing an ldf file and specifying the DN of the user and a changetype of delete: CSVDE
There is a companion utility, CSVDE, that uses mostly the same commands as LDIFDE, but the input and output is in a comma-separated file. Figure 2 shows the results of taking the comma-separated output of the following command and importing it into an Excel spreadsheet:
Note: Import operations with CSVDE are "add" only, and CSVDE does not offer the ability to modify or delete objects.

Figure 2. Output of CSVDE command imported into Excel Spreadsheet.

[IMAGE]

Obviously there are more powerful scripting tools for bulk import and export of Active Directory objects, such as VBScript and ADSI and other tools in the Windows .NET Framework. The nice thing about LDIFDE and CSVDE is they are simple enough for the average non-programmer to use, and if you don't have the time or expertise to develop a complex script, these tools will probably do the job. There isn't a lot of help from Microsoft on this but I searched Google and found several sites offering e-books (online books) for a small fee. The most impressive one was Jumbo Scripts by Guy Thomas. It covers LDIFDE, CSVDE and Logon scripts. That site has a plethora of free "How To" pages as well as books containing samples of using LDIFDE, CSVDE and WSH for exporting and importing objects into Active Directory.

Gary Olsen is a systems software engineer for Hewlett-Packard in Global Solutions Engineering. He authored Windows 2000: Active Directory Design and Deployment and co-authored Windows Server 2003 on HP ProLiant Servers.

Rate this Tip
To rate tips, you must be a member of SearchWindowsServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Server Room Design - Planning, Cooling, Maintenance
HomeTopicsBlogsITKnowledge ExchangeTipsNewsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2004 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts