Problem solve Get help with specific problems with your technologies, process and projects.

Defragmenting the Active Directory object database

All Active Directory objects are stored in a database that you should periodically defragment; here's how.

When you defrag, you can save disk space and improve performance. This tip suggests two ways to defrag the Active Directory object database.

All objects in an Active Directory hosted on a Win 2000 Server are stored in a database named NTDIS.DIT and managed by an underlying Extensible Storage Engine (ESE). When filling pages, the ESE sacrifices memory efficiency for speed. Two defragmentation techniques recover the sacrificed memory.

Online Defragmentation:

The ESE performs online defragmentation periodically as part of the garbage-collection process. The process rearranges database pages and makes space available for new Active Directory objects. To change the online defragmentation period you need to change the garbage-collection period by modifying the garbageCollPeriod attribute in the enterprise-wide DS configuration object. Do this using any Active Directory editing tool, including Adsiedit.msc, Ldp.exe, or ADSI scripts. The path for the garbageCollPeriod of Server1 in the domain would be:

CN=Directory Service,CN=Windows 

For details on other activities involved in the garbage collection process, check out

Online defragmentation frees up space within the Active Directory object database (NTDS.DIT) to make room for new objects. However, it does not reduce the size of NTDS.DIT, and therefore cannot return unused memory to the file system. To do that you need to take the database offline.

Offline Defragmentation:

  1. Begin by backing up Active Directory, which can be done before taking the controller offline. (Use the backup wizard and either select the option to back up everything on the computer or select the option to back up the System State.)
  2. Reboot the domain controller and press F8 to display advanced options. Choose Directory Services Restore Mode and press Enter twice.
  3. Log on using the Administrator account. You'll need administrator permission to perform the defragmentation, and the security context and protection is quite different offline. If you have trouble, check out the note on the offline Security Accounts Manager (SAM)
  4. Click Start, select Programs, then Accessories, click Command Prompt, then type ntdsutil and press Enter.
  5. Type files, press Enter, type info, press Enter.
  6. You will now see the path and size of the Active Directory database and log files. Write down the path and note the size.
  7. Type compact to drive:directory where drive:directory is where you want to compacted file and has enough space to accept it.
  8. Type quit then Enter, then quit again to return to the command prompt.
  9. Copy the NTDS.DIT file from drive:directory to the path you wrote down in step 6.
  10. Reboot normally

For more background on defragmentation, check out these two articles:

Kevin Sharp is a registered professional engineer, writer, and yoga teacher living in Tucson, Arizona, and gains his expertise from a variety of professional activities. His engineering outlets include Web consulting for Supply Chain Systems Magazine, focusing on the fulfillment side of electronic commerce.

Did you like this tip? Let us know. You can drop a line to sound off.

Related Book

Windows 2000 Active Directory
Author : Joe Casad
Publisher : Osborne
Published : May 2000
Summary :
Explores what you can do in the new world of Active Directory, rather than just showing how to make a Windows 2000 network look and act like an NT 4.0 network. The Windows 2000 general reference books will not be able to approach this topic with this depth. Tech reviewed by the pros--Systems administrators, analysts, and MCSEs who are on the beta program testing Windows 2000 and Active Directory for their companies in the Microsoft Partnership Program have checked the book for accuracy and excellence. Expert author--Joe Casad is the best-selling author of SAMS Teach Yourself TCP/IP in 24 Hours, and two MCSE study guides from New Riders. In the industry, he is considered a networking expert and engineer. Full section on Total Cost of Ownership--Provides specific tips and examples that administrators can immediately use to reduce their networking costs. Topics include service publication, group policy integration, and Directory Object Extension. 16 pages of network blueprints--Illustrate the Active Directory Object naming system.

Dig Deeper on Windows administration tools