Skip to main content
Jorge Bernhardt Jorge Bernhardt
  1. Posts/

How to compact the Active Directory Database

·282 words·2 mins· 100 views · 5 likes ·
Active Directory Database Microsoft Microsoft Windows NtdsUtil.exe

In this mini-post, I want to show you how to perform an offline defragmentation of the Active Directory database. To perform the maintenance of the AD DS database offline, we will use the NtdsUtil.exe command line tool. At the end of the defragmentation, we will obtain a compact AD DS database. Requirements: The minimum required to complete the following tasks is Membership in the Local Administrators group. Important: Before performing the tasks described in this post, you must perform a system state backup using Windows Server Backup. To compact the Active Directory database, use the following procedure: The commands used in this procedure require that you run them from an elevated Command Prompt. Open a command prompt as Administrator and run the following commands.

Stop the Active Directory Domain Service.>

Stop the Active Directory Domain Service. #

To perform offline defragmentation, you must stop the Active Directory Domain Service (NTDS). Run the following command as an administrator and answer “Y” to accept stopping additional services.

net stop ntds

Net stop ntds

Run the NtdsUtil.exe commands>

Run the NtdsUtil.exe commands #

by running the following commands, you will compact the database and check the integrity of the database.

Activate instance NTDS
Files
Compact to c:\
Integrity
Quit
Quit

If the defragmentation completes successfully, copy the new database file to the c:\Windows\ NTDS directory and then delete the log files.

copy c:\ntds.dit c:\windows\NTDS\ntds.dit
del c:\Windows\NTDS\*.log

Active Directory Database

Start the Active Directory Domain Service.>

Start the Active Directory Domain Service. #

Once the tasks have finished, we will start the Active Directory Domain Service (NTDS) again. Run the following command as administrator.

net start ntds

If you want to know more about AD DS database compaction, check out this link.