Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 2003

Scripting with IADsTools

Solving problems in your AD environment
RSS
Subscribe to Windows IT Pro | See More Active Directory (AD) Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

I always feel good when I find a nifty tool that solves some administrative problem. I feel even better when I can script against that tool to automate a task within my environment. IADsTools is such a tool. Found in Windows 2000 Support Tools, IADsTools is a DLL, not a simple command-line utility that you can call. However, it is a COM-based ActiveX automation object that you can invoke from your Windows Script Host (WSH) scripts to perform a variety of actions related to Active Directory (AD), AD replication, and Group Policy. An associated Microsoft Word document in the Win2K Support Tools installation directory describes IADsTools's functions. Let's take a look at a few sample scripts to illustrate the power of some of the more valuable functions that IADsTools provides.

Installing IADsTools
After you install Win2K Support Tools from the \support\tools folder of the Win2K Server CD-ROM, the IADsTools.dll and .doc files will be in the \%programfiles%\support tools directory. To begin using the DLL in your WSH scripts, the DLL must be registered in the registry as a COM object. Open a registry editor and look in HKEY_CLASSES_ROOT for entries beginning with IADsTools. If you find these entries, you're ready to start scripting. If not, you need to register the DLL manually. To do so, start a Windows command shell, navigate to the Win2K Support Tools installation directory, and type

regsvr32 iadstools.dll

After you successfully register the DLL in the system registry , you can begin scripting against it. You can also unregister the DLL, if necessary, by typing

regsvr32 /u iadstools.dll

Before You Get Started
Before you use IADsTools, you should be aware of a few bugs and what steps you can take to work around these problems. The Microsoft articles "Memory Leak with the GetDirectPartnersEx() Function in Iadstools.dll" (http://support.microsoft.com/?kbid=305832) and "Memory Leak Calling the DsGetDcName() or DsGetSiteName() Function" (http://support.microsoft.com/?kbid=300917) describe some memory leaks within IADsTools. The version of Win2K Support Tools that comes with Win2K Service Pack 3 (SP3) corrects these bugs. I strongly recommend that you implement both Win2K SP3 and the Win2K Support Tools update on the servers and clients on which you plan to run IADsTools scripts. You can download Win2K SP3 at http://www.microsoft.com/windows2000/downloads/servicepacks/sp3/default.asp and download the Win2K Support Tools update at http://www.microsoft.com/windows2000/downloads/servicepacks/sp3/supporttools.asp.

Preparing to Use IADsTools
To take advantage of IADsTools's functions, you need to configure your scripts to use the DLL. I used VBScript to prepare all the sample scripts in this article, but you can use any WSH-supported scripting language. To begin, an IADsTools script must include a call to instantiate the scripting object:

Set objIADS=CreateObject
  ("IADsTools.DCFunctions")

In this case, the COM programmatic identifier (ProgID) IADsTools.DCFunctions creates an object called objIADS that exposes the functions we're interested in. I also suggest enabling verbose logging of the IADsTools calls in IADsTools scripts—the DLL provides a function called EnableDebugLogging() for this purpose. I typically enable logging in my scripts immediately after I instantiate the IADsTools object by including the following call:

objIADS.EnableDebugLogging(3)
   Previous  [1]  2  3  Next 


Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...


Active Directory (AD) Whitepapers Sustainable Compliance: How to reconnect compliance, security and business goals

Managing Unix/Linux with Microsoft System Center Operations Manager 2007 Cross Platform Extensions Beta

Addressing the Insider Threat with NetIQ Security and Administration Solutions

Related Events Concrete Ways to Make Sure Your SharePoint Deployment Doesn't Blow Up

Introduction to Identity Lifecycle Manager "2"

Check out our list of Free Email Newsletters!

Active Directory (AD) eBooks Keeping Your Business Safe from Attack: Monitoring and Managing Your Network Security

Keeping Your Business Safe from Attack: Encryption and Certificate Services

Windows 2003: Active Directory Administration Essentials

Related Active Directory (AD) Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing