Skip to content
Knowledge base

Active Directory forest recovery after a cyberattack: a plan to have before you need it

According to Microsoft, recovering an entire Active Directory forest is the last resort. When it is needed, though, preparation decides how quickly you are back: backups of at least two writable domain controllers per domain, known DSRM passwords, a designated restore DC, an isolated network and a rehearsed procedure with two krbtgt resets.

Saturday, 3:40 a.m. Monitoring reports that no domain controller is replicating, file servers are rejecting logons, and the same ransom note sits on every domain controller. Backups exist, but nobody on the team has ever restored an entire Active Directory forest, and nobody knows which domain controller to start with.

Without the directory there is no authentication, so the systems people least associate with cybersecurity stop as well: accounting, the warehouse, email. Microsoft covers Active Directory forest recovery in a dedicated guide and treats it as a template for a plan that every organisation has to adapt to itself. That plan cannot be written in the middle of an incident.

When do you need to recover an entire Active Directory forest?

You recover the whole forest when a failure affects every domain controller and none of them can function normally. Microsoft’s guide describes exactly that situation, not the failure of a single server.

Among its examples, Microsoft lists logical corruption of all domain controllers, a rogue administrator compromising the environment, a script that spreads data corruption across the forest, malicious schema changes and malicious software on domain controllers. Another signal is a situation where no domain controller can replicate with its partners, no changes can be made anywhere and no new domain controller can be installed.

Microsoft stresses that a full forest recovery should be the last option, and that the decision should follow identifying the cause and evaluating other remedies, ideally with vendor support. If a domain controller backup has been exposed but the leaked credentials have not been used to change directory data, resetting the passwords of users, computers, trusts and managed service accounts may be enough.

An important caveat: the guide does not cover security recommendations for a forest that has been compromised by an attacker, and refers to separate guidance on securing Active Directory for that. A post-attack plan therefore needs two layers: technical recovery and removing the effects of the breach.

What do you lose when you recover the forest from backup?

Recovery returns each domain to the state of its last trusted backup, so everything that changed afterwards is gone. Microsoft lists at least three categories of loss: objects added after the backup, updates to existing objects, and changes to the configuration or schema partition.

For HR, that means new starters’ accounts to create again; for administrators, permission and group changes to rebuild from documentation or tickets. The older the backup, the longer the list, but also the lower the risk that the backup contains the effects of the attack.

Recovery needs two passwords that are easy to forget. You must know the password of a domain administrator account in every domain of the forest, preferably the built-in Administrator account, and the Directory Services Restore Mode (DSRM) password, without which a domain controller’s system state cannot be restored.

Microsoft recommends archiving the history of these passwords in a safe place for as long as the backups are valid. The DSRM password can also be synchronised with a domain account in advance, but that is a preparatory step that cannot be done on the day of the failure.

Which domain controller backup should you choose for recovery?

The best backup is one that can be restored successfully, was taken a few days before the failure and contains as much useful data as possible. Microsoft recommends regularly backing up at least two writable domain controllers in each domain, so that you have a choice.

A backup of a read-only domain controller (RODC) cannot be used to restore a writable one. System state backups should not be restored to a different server either, and restoring one to a new installation of Windows Server is not supported. If the directory has to come back on different hardware, you need full server backups.

If the time of failure is unknown, you have to look for the backup that holds the last safe state of the forest. Microsoft suggests Dsamain.exe, which exposes data from a backup or database snapshot as an LDAP server without restarting a domain controller in DSRM. It also recommends daily logs of the directory’s health, so that the approximate start of a failure can be identified.

Key points:

  • The backup must come from a writable domain controller and be taken a few days before the failure.
  • Without the DSRM password and the domain administrator password, recovery cannot start.
  • A system state backup is not restored to a different server; for different hardware you need a full server backup.

Choosing between recentness and safety is a trade-off Microsoft describes explicitly: a newer backup recovers more, but may bring dangerous data back into the forest. After a ransomware attack, we cover this trade-off in more detail in the article on the clean restore point.

Which domain controller should you restore first?

The first to be restored is a writable domain controller in the forest root domain, followed by one domain controller in each domain, always the parent domain before the child. The forest root domain stores the Schema Admins and Enterprise Admins groups, maintains the trust hierarchy and usually holds the forest’s root DNS zone.

Microsoft recommends designating a dedicated restore domain controller in each domain. Such a domain controller has the same configuration as in testing, so the procedure can be scripted and nobody has to work out on the day of the failure which roles each server held.

The selection criteria in the guide are specific: a writable domain controller (mandatory), ideally a virtual machine on a hypervisor that supports VM-GenerationID, accessible physically or on a virtual network, with a good full server backup, running DNS and acting as a global catalog. It should not use BitLocker Network Unlock as its only key protector, because network unlock will not work before the directory is restored.

Restoring an operations master (FSMO) role holder for convenience is not recommended, because you seize all roles anyway. The exception is SYSVOL: a backup from the PDC emulator usually has the best copy of it.

Why should you recover the forest on an isolated network?

Isolation prevents corrupted or malicious data from replicating back into the recovered forest. Microsoft recommends shutting down all writable domain controllers before the first recovered one returns to production, and especially the FSMO role holders.

Virtual domain controllers are moved to a virtual network cut off from production, where further domain controllers can also be cloned and tested before they go back. For physical domain controllers, you disconnect the network cable of the first server to be restored and, where possible, of the others too.

In a large forest spread across many locations, it is hard to guarantee that every writable domain controller is shut down. That is why steps such as resetting the computer account, resetting krbtgt and cleaning up metadata are designed to prevent replication with a domain controller that happens to still be running. Only taking writable domain controllers offline gives certainty, though, so it is worth having tools to shut servers down remotely.

Read-only domain controllers can keep working in the meantime, because no domain controller replicates changes from them. They will serve logons to resources cached on them, but password changes will not work until the writable domain controllers are back.

What does restoring your first domain controller involve?

The first domain controller in a domain goes through a non-authoritative restore of AD DS and an authoritative restore of SYSVOL, followed by a series of clean-up tasks. Microsoft requires an Active Directory-aware backup application, recommending Windows Server Backup.

The authoritative restore of SYSVOL is performed only on the first domain controller being restored; on others it leads to replication conflicts. After the restart, you check whether the failure affected the data on the restored domain controller, and if it did, you restore again from a different backup. The domain controller joins the production network only after this verification.

From there the guide walks through steps whose order you need to have written down. On the first domain controller in the forest root domain you seize all FSMO roles, clean up the metadata of the other writable domain controllers, bring up DNS and delete NS records of domain controllers that no longer exist. The available RID pool is raised by 100,000, so that new objects do not receive the SIDs of objects created after the backup, which may still hold permissions.

Next, the domain controller’s computer account password is reset twice and the krbtgt password twice, and in a multi-domain forest, if the restored domain controller was a global catalog before the failure, that role is removed, to avoid introducing lingering objects from backups taken at different times. Finally, the time service is configured on the PDC emulator of the forest root domain.

Once one restored domain controller is running in each domain, they are joined on a common isolated network, replication is checked with repadmin and DCDiag, a global catalog is added in the forest root domain and new backups are taken of the restored domain controllers. Only then are further domain controllers deployed.

Why do you reset the krbtgt password twice?

The krbtgt account remembers its two most recent passwords, so only the second reset removes the pre-failure password from the history. Microsoft explains that resetting twice clears old passwords, so that no other domain controller can replicate with the restored one using an old password.

You have to wait between the resets. According to the same page, the gap should be 10 hours, because that is the default maximum lifetime for user tickets and service tickets; if the domain uses longer values, the gap must be greater than the configured value.

The procedure applies to writable domain controllers. If RODCs are to return in the recovered forest, you must not delete their krbtgt accounts in the krbtgt_number format. A custom password filter on a domain controller may in turn cause an error during the reset, for which Microsoft describes a workaround in a separate knowledge base article.

For the plan, this means one thing: the recovery time cannot assume that krbtgt can be “sorted out” in a few minutes. The gap between resets is part of the schedule that the board should know before an incident.

What should you add to recovery when an attacker has taken over the forest?

If the failure was caused by a breach, the procedure adds a reset of all administrative accounts before further domain controllers are installed. Microsoft lists members of the Enterprise Admins, Domain Admins, Schema Admins, Server Operators and Account Operators groups, as well as the complete krbtgt password reset.

An attacker with administrator rights may also have obtained data that lets them authenticate as group managed service accounts (gMSA). The guide then recommends replacing the passwords of these accounts and, where the database of a writable domain controller was compromised, creating a new KDS root key and recreating the gMSA accounts. We cover these accounts in the article on gMSA without static passwords.

If user accounts are suspected to be compromised, you need to plan a password reset for every user in the domain, and after a breach trust passwords can be reset too. These steps affect every employee, so the announcement and the way new passwords are handed out are worth preparing together with the technical plan.

Other security recommendations lie outside the recovery guide. Paths to domain administrator rights, delegations and weak settings are best found before an attack, because after a restore from backup they come back with the directory. Identity in the cloud belongs in the same plan: a backup of the on-premises directory does not replace a Microsoft Entra ID backup.

How do you prepare a forest recovery plan before you need it?

The plan is a documented procedure tested in a lab using production backups and updated after every significant change. Microsoft recommends a detailed topology map of the forest and practising recovery at least once a year, as well as after changes to Enterprise Admins and Domain Admins membership.

Every element of the plan should have an owner and a way of checking that it works before it is needed.

Plan elementWhat to prepareHow to check
Forest mapList of domains and domain controllers with FSMO roles, global catalog, DNS, backup and trustsComparison with the directory after every change
BackupsAt least two writable domain controllers per domain, full server backup and system state backupRestore in a lab from a production backup
PasswordsDomain administrator and DSRM password for each domain, with history for the backup validity periodAccess control to the password vault
Restore domain controllerA designated writable domain controller in each domain, ideally virtualThe same domain controller in every exercise
Isolated networkA virtual network or a procedure for disconnecting physical domain controllersStarting a restored domain controller with no contact with production
Recovery keysBitLocker keys and other emergency information available without the directoryReading a key with AD switched off
Post-breach stepsList of accounts to reset, gMSA, KDS key, announcement to employeesReview when privileged groups change
ScheduleOrder of domains, gap between krbtgt resets, decisions to be madeTiming measured in the exercise

The recovery keys row is easy to overlook. Microsoft reminds you that if domain controller volumes are encrypted, BitLocker keys may be needed; if your organisation stores them in the directory, they will be unavailable together with it on the day of the failure.

Part of the preparation concerns the backups themselves: how they are protected, where they are kept and whether they are merely a storage array snapshot. We explain the difference between a snapshot and a backup in the article on snapshots and backups.

How can nFlo help you prepare for Active Directory recovery?

We help from two sides: before the directory ever has to be restored, and in what it is restored from.

The Active Directory Security Audit, using BloodHound, PingCastle and Purple Knight, shows attack paths to domain administrator rights, excessive permissions, delegations and trusts, and ends with a prioritised hardening plan. It is a list of things that would come back with the directory after a restore from backup.

As part of Backup and Disaster Recovery, we design backups following the 3-2-1 rule with immutable copies and regularly test restore procedures. If you want to check whether your organisation can recover its AD forest without improvising, contact us.

What else is worth knowing about Active Directory forest recovery?

Can a virtual machine snapshot of a domain controller replace a backup?

It should not. Microsoft allows rolling a virtual machine back to a known good state with a snapshot, but does not recommend it as the main method, because snapshots come with caveats such as disk space on the host. Regular backups should be the main means of recovery.

Can AD forest recovery be fully automated?

No. Microsoft says that, because of the complexity of the process, there is no end-to-end automation. Recovery steps are, however, carried out mainly with command-line tools such as Ntdsutil, so they can be scripted, provided the scripts are tested and updated after every change to the environment.

Can a domain controller’s system state backup be restored to a different server?

Microsoft does not recommend it, and restoring a system state backup to a new installation of Windows Server is not supported. If Active Directory has to come back on different hardware, you need to take full server backups in advance and plan a full server recovery.

How can you shorten forest recovery time?

Microsoft lists, among other things, a full Windows Server Backup that allows either bare-metal recovery or a system state recovery, cloning virtualized domain controllers, Install From Media (IFM) and practising the plan at least once a year. Bare-metal recovery completes faster than a system state restore, because it works at the binary level.

How long is a domain controller backup usable for recovery?

Microsoft ties the useful life of a backup to the tombstone lifetime, and with the Active Directory Recycle Bin enabled, to the lower of the deletedObjectLifetime and tombstoneLifetime values. An older backup cannot be used to recover the forest, which is why it is worth archiving the administrator and DSRM passwords for the same period.

Share:

Talk to an expert

Have questions about this topic? Get in touch with our specialist.

Sales Representative
Grzegorz Gnych

Grzegorz Gnych

Sales Representative

Response within 24 hours
Expert consultation
Individual approach

Providing your phone number will speed up contact.

Want to Reduce IT Risk and Costs?

Book a consultation - we respond within 24h

Response in 24h Custom quote No obligations