Site Meter Microsoft Talk » Blog Archive » Essential Tools to Manage Active Directory

Essential Tools to Manage Active Directory

by Alpesh Nakar

hd2-windows CSVDE

The Comma-Separated Values Data Exchange tool, known as CSVDE, allows you to import new objects into Active Directory using a CSV source file; it also provides you with the ability to export existing objects to a CSV file. CSVDE can’t be used to modify existing objects; when you are using this tool in import mode you can only create brand-new objects.

Exporting a list of existing objects with CSVDE is fairly simple. Here’s how you’d export your Active Directory objects to a file called ad.csv:

csvde –f ad.csv

The –f switch indicates that the name of the output file follows. But you must be aware of the fact that, depending on your environment, this basic syntax could result in a huge and unwieldy output file. To restrict the tool to export objects only within a particular organizational unit (OU), you could modify the statement as follows:

csvde –f UsersOU.csv –d ou=Users,dc=contoso,dc=com

Let’s further say that you’re only interested in exporting user objects into your CSV file. In that case, you can add the –r switch, which allows you to specify a Lightweight Directory Access Protocol (LDAP) filter for the search, and the –l switch, which restricts the number of attributes that are exported (note that the following is all on one line):

csvde –f UsersOnly.csv –d ou=Users,dc=contoso,dc=com –r
    "(&(objectcategory=person)(objectclass=user))" –l
    DN,objectClass,description

The –i switch allows you to import objects into Active Directory from a source CSV file. However, creating user objects with CSVDE has one critical limitation: you can’t set user passwords with it. Because of this, I’d avoid using CSVDE to create user objects.

LDIFDE

Active Directory provides a second built-in tool for bulk user operations, called LDIFDE, and it is more powerful and flexible than CSVDE. In addition to creating new objects, LDIFDE can also modify and delete existing objects and even extend the Active Directory schema. The trade-off for LDIFDE’s flexibility is that the necessary input file, which is referred to as an LDIF file with the extension .ldf, uses a more complex format than the simple CSV file. (With a little work you can also configure user passwords, but I’ll get to that in a moment.)

Let’s start with a simple example, exporting users in an OU to an LDF file (note that the following is all on one line):

ldifde -f users.ldf -s DC1.contoso.com -d "ou=UsersOU,dc=contoso,dc=com"
       –r "(&(objectcategory=person)(objectclass=user))"

As with most command-line tools, you can find a full explanation of the LDIFDE switches by running the LDIFDE /? command. (Note that the switches are actually the same for both the CSVDE and LDIFDE commands.)

The real power of LDIFDE is in creating and manipulating objects. Before doing this, however, you first need to create an input file. The following creates two new user accounts called afuller and rking; to create the input file, enter the text in Notepad (or your favorite plain-text editor) and save it as NewUsers.ldf:

dn: CN=afuller, OU=UsersOU, DC=contoso, DC=com
changetype: add
cn: afuller
objectClass: user
samAccountName: afuller 

dn: CN=rking, OU=UsersOU, DC=contoso, DC=com
changetype: add
cn: rking
objectClass: user
samAccountName: rking 

Once you’ve finished creating the file, run the following command:

ldifde –i –f NewUsers.ldf –s DC1.contoso.com

The only new switch here is -i, which, you can probably guess for yourself, denotes that this is an import operation instead of an export.

When modifying or deleting existing objects, the syntax for the LDIFDE command doesn’t change; instead, you modify the contents of the LDF file. To change the description field of the user accounts, create a text file called ModifyUsers.ldf, such as the one shown in Figure 2.

Figure 2 The ModifyUsers LDF file

Figure 2 The ModifyUsers LDF file (Click the image for a smaller view)

Figure 2 The ModifyUsers LDF file

Figure 2 The ModifyUsers LDF file (Click the image for a larger view)

You import the changes by running the same LDIFDE command syntax as before, specifying the new LDF file name after the -f switch. The LDF format for deleting objects is even simpler; to delete the users you’ve been working with, create a file called DeleteUsers.ldf and enter the following:

dn: CN=afuller OU=UsersOU, DC=contoso, DC=com
changetype: delete

dn: CN=rking, OU=UsersOU, DC=contoso, DC=com
changetype: delete

Note that unlike CSVDE, LDIFDE is capable of configuring user passwords. Before you can configure the unicodePWD attribute for a user account, however, you must configure secure sockets layer/transport layer security (SSL/TLS) encryption on your domain controllers.

Moreover, LDIFDE can create and modify any type of Active Directory object, not just user accounts. The following LDF file, for example, will create a custom schema extension called EmployeeID-example in the schema of the contoso.com forest:

dn: cn=EmployeeID-example,cn=Schema,
cn=Configuration,dc=contoso,dc=com
changetype: add
adminDisplayName: EmployeeID-Example
attributeID: 1.2.3.4.5.6.6.6.7
attributeSyntax: 2.5.5.6
cn: Employee-ID
instanceType: 4
isSingleValued: True
lDAPDisplayName: employeeID-example

Because LDIFDE files use the industry-standard LDAP file format, third-party applications that need to modify the Active Directory schema will often supply LDF files you can use to examine and approve the changes before applying them to your production environment.

In addition to tools for bulk import and export operations, Windows Server 2003 also includes a built-in toolset that lets you create, delete, and modify various Active Directory objects as well as perform queries for objects that meet certain criteria. (Note that these tools, dsadd, dsrm, dsget, and dsquery, are not supported under Windows 2000 Active Directory.)

Recommended: 

Friday Video: Windows Sounds and logos | Windows Live: Folder Share


Leave a Reply


About Microsoft Talk

This blog is for you all Microsoft enthusiasts out there. Somehow we happen to use Microsoft directly or indirectly. Microsoft revolutised what we call IT today. We are connected with Microsoft in some or the other way. Depending on which side of the fence you are on, you take note, Microsoft is everywhere. If you use non-MS products, your ISP, your web-host, yours truly - somebody somewhere is using Microsoft or is a spin off as a result of something that Microsoft had to offer then. Invariable, we do end end up using Microsoft Technologies. What do you think?

With MSTALKONLINE, you will come to experience Microsoft Technologies, that you experience day to day. In the weeks to come, I will focus on latest and greatest happenings in the land of Microsoft and your comments and suggestions will be one of the driving factors

Microsoft Talk Author(s)
    » Alpesh-Nakar

Technology Channel Posts

  • And We’re Back!
    Hi everyone! Phew! We are back in action (as you can see). Did you miss me? I missed you! Group hug! Too much? Okay. I’ll behave. I am very glad to be back in action and posting here on [...]
  • Sometimes Old Is New (to You)
    While looking for something else, I came upon an older article about a copy of a well respected subwoofer by Hsu Research. The project is very straightforward, using sound building techniques, and [...]
  • Technical Difficulties
    Hello everyone. As you likely already know, many of the sites on the 451press network are down and have been down for some time (what seems like forever!). I would like to apologize on behalf [...]
  • ATi Brings Back A Winner
    For the last couple of years, there has been a huge hole in the video card market. It was 2006 when the last ATi All-in-Wonder was produced, and nVidia had discontinued their similar offering before [...]
  • The Search for Truth… (continued)
    On the other side are aligned a much smaller number of scientists, some dedicated amateurs, very little money (the grants get taken away as soon as it’s clear the research is leading away from AGW) [...]
  • Introduction to Forums – A Warning
    While getting on to a forum and posting (especially for the first time) can be a lot of fun and exhilarating, there is a sobering note that comes along with joining forums (and with communicating [...]
  • Home Theater On The Cheap Rides Again
    Now and then, a choice comes up which makes sense right away, yet allows expansion capability and growth potential. It is not often that a Home Theater in a Box will be acceptable to any serious [...]
  • The Search for Truth…
    In Using the Net and Finding the Truth I used the search for information about Anthropogenetic Global Warming (AGW – Human-caused Global Warming) to talk about Internet use. Here is an example [...]
  • From Time Window to Time Portal
    DCM Time Windows were one of the speakers that defined the ‘cheapskate’ high end of the late ‘70s. Looking at the speaker was anything but awe inspiring. It was a small two-way tower, with [...]
  • Introducing Mr. JM
    I pretty much grew up with computers as part of my life. I had them at school and used typing, games, etc programs. I remember using dot matrix printers and planning the most basic version of [...]

Hot Off The Press

  • Weekly Forecast: View To A Kill
    (Hint: Play song and read at the same time!) Mystery, intrigue and dances in the fire, or a least a little snarkiness, are the keynotes of this dramatic week as the planet of secrets, Pluto, [...]
  • Some Summer Music Pics from Five Magazine
    That's this SUNDAY in TAOS....go camping too. Brave Combo Nearly thirty years ago, someone classifi ed Denton, Texas’ Brave Combo as a new wave polka band, which they are. Th ey even won [...]
  • So You Think You Can Dance - Will B. Wingfield
    So, let me get this party started this season.  I've been watching half-heartedly until tonight, but tonight, some of these guys really got my attention tonight.  And, at the ripe age of [...]
  • July Book Blowout
    I can’t quite remember how I found it, but Mrs. S at Blue Archipelago is hosting a reading challenge for the month of July and I have decided to take part. Usually I’m a bit wary of joining [...]
  • Kids Learn Space Science with the Zula Patrol
    Yesterday I watched the Zula Patrol premiere as part of the qubo block on ION. Besides the kind of annoying theme song at the beginning I found this to be a pretty good educational cartoon for [...]
  • News from Five Magazine
    At last! Let's see how far I get. www.readfive.comThis summer in Taos Joan Armitrading will perform. Here an interview by Bill Nevins with Joan A. “Under the surface there was always a [...]
  • Idol Teachers
    I just watched a video clip. It was from the pilot episode of a potential new sitcom called Teachers. The pilot seems to revolve around the life of a young, fresh-faced teacher named Tim Donnely, [...]
  • Love Question Nine
    Woo hoo! I’m glad to be back and doing the Love Questions meme from Short Sweet Love Poems. I do enjoy the questions and reading the thoughts of others. This week we have a very interesting, [...]
  • Fruits of the Spirit: Be kind to each other
    But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness and self-control. Against such things there is no law. Galatians 5:22-23 Kindness is [...]
  • Happy Day After the 4th!
    I'm sorry I didn't post yesterday Jolie-Pitt fans. One weekend a month we have an 8 year old girl for respite, and things kind of go a bit haywire when that happens. Going from a 2 children home to a [...]