MOC method:
1. Log onto the computer as the default administrator of the domainsomething.local domain.
2. Open a command-prompt window. To enable Directory Services Restore Mode on the next reboot, key bcdedit /set safeboot dsrepair, and then press Enter.
3. Close the command-prompt window and restart the computer.
4. When the computer restarts, log onto the local computer (not the domain) using the Directory Services Restore Mode username and password. The username should be Administrator and the password should be configured one. The Windows Desktop should indicate that the domain controller is operating in Safe Mode.
5. Open a command-prompt window, key NTDSUTIL, and press Enter.
6. Key activate instance ntds and press Enter.
7. Key files and press Enter. The File Maintenance prompt is displayed.
8. Key ? and press Enter. Notice that you have several options at this prompt. You can check the Active Directory database integrity, move the database, and move the database log files.
9. Key info and press Enter. This command displays the current location of the Active Directory database (ntds.dit), the backup directory, and the log files directory.
10. To perform offline compaction of the database, key compact to c:\ and press Enter. The database is compacted and you are given directions to replace the existing database.
11. Key quit and press Enter. The ntdsutil prompt is displayed.
12. Key quit again and press Enter. You are returned to the command prompt.
13. Key move %systemroot%\ntds\ntds.dit c:\ntds.old and press Enter. This saves your old Active Directory database in case you have trouble with the newly compacted database. You can delete this copy after you verify that the newly compacted database loads correctly after you restart the computer. Otherwise, you can use the ntds.old file to replace the compacted database.
14. Key move %systemroot%\ntds\*.log c:\ and press Enter. This command moves the former Active Directory database log files to the c:\ drive.
15. Key move c:\ntds.dit %systemroot%\ntds\ntds.dit and press Enter. This command places the newly compacted database in the appropriate location to load when you restart the computer.
16. Key dir c:\ntds.old and press Enter. Statistics for the previous copy of the Active Directory database are displayed.
17. Key dir %systemroot%\ntds\ntds.dit and press Enter. The Active Directory database is compacted. Statistics for the newly compacted Active Directory database are displayed. Compare the size of the ntds.old file to the size of the ntds.dit file. You might not see a size difference between the compacted file and the original file, because the database in the lab has not had a chance to become fragmented. On a computer that hosts an Active Directory database that experiences a large number of changes, you could reduce the amount of space that the Active Directory database occupied with the compacting process.
18. To remove the Directory Services Restore Mode boot option, key
bcdedit /deletevalue safeboot and press Enter. Restart the domain controller.
NOTE If you encounter Directory Services errors in the Windows Event Viewer when you restart the computer, you will need to restart again in Directory Services Restore mode. You will then open a command-prompt window and key move c:\ntds.old %systemroot%\ntds.ntds.dit, which will replace the compacted copy of the database with the old copy of the Active Directory database. You will also need to copy the old log files from the c:\ drive to the %systemroot%\ntds folder.
19. If the computer starts properly without errors, log on as the default administrator of the domainsomething domain. Open a command-prompt window. Key del c:\ntds.old c:\res*.log c:\edb*.log and press Enter. This will delete the old Active Directory database and log files. Close the command-prompt window.
If you’d like to learn more about Active Directory, I’d recommend that you get hold of these Active Directory Training Videos. If you truly want to Learn Active Directory you won’t find better training than this.