If you delete an Active Directory user, it is not immediately removed from the AD catalog and can be restored. This guide explains how to restore accidentally deleted Active Directory objects.
When an AD object is deleted, it is moved to the hidden Deleted Objects container, and its isDeleted attribute is set to True.
Deleted objects are permanently removed from Active Directory after 180 days by default. This retention period is defined by the tombstoneLifetime (TSL) attribute and managed by the AD garbage collection automatic process.
Check the TSL (tombstoneLifetime) value in your domain using the PowerShell command (replace “dc=theitbros,dc=com” with your domain):
Note that in environments with AD Recycle Bin enabled, object retention may also depend on the deleted object lifetime and recycled object lifetime settings.
Active Directory Recycle Bin
The Active Directory Recycle Bin is an ADDS feature available in Windows Server 2008 R2 and later versions. It makes it much easier to recover deleted objects (such as user accounts, groups, or computer accounts) in an Active Directory environment.
There are two ways to restore deleted objects in Active Directory, depending on whether the Active Directory Recycle Bin is enabled in the domain.
Once enabled, the AD Recycle Bin cannot be disabled
If objects were deleted before the Recycle Bin was enabled, they may not become fully recoverable through the Recycle Bin. You need to always check the state of deleted objects before enabling the feature.
Enabling Active Directory Recycle Bin
The AD Recycle Bin is not enabled by default. Therefore, you need to make sure that it is enabled before proceeding to recover a deleted object.
Run the following PowerShell command:
Get-ADOptionalFeature "Recycle Bin Feature" | select-object name, EnabledScopes
If the EnabledScopes property is empty, the Recycle Bin is not enabled, and you cannot use it to restore deleted Active Directory users. In this case, you should proceed with the method of restoring AD object without using AD Recycle Bin.
On the other hand, the below screenshot shows the result if the AD Recycle Bin is enabled.
How to Restore Deleted User without AD Recycle Bin
If the Active Directory Recycle Bin is not enabled in a domain, you can use the LDP.EXE or ADRESTORE.EXE tools to restore deleted objects.
Using LDP.EXE to Restore Deleted Active Directory User
LDP.EXE is a built-in tool available by default on AD domain controllers (can be installed on client computers via RSAT). In this example, the user John Doe was deleted and will be restored using LDP.
Run the command with an account that is a member of the Domain Admins or Enterprise Admins group:
ldp.exe
Click Connection → Connect and enter the domain controller name.
Click Connection → Bind→ Bind as currently logged on user
Verify that authentication was successful.
Click View → Tree
Select your domain’s base DN from the dropdown list and click OK.
Navigate to “DC=DOMAIN,DC=TLD” → “CN=Deleted Objects” and double-click the deleted user. You will see the object’s details on the output pane. As you can see, the isDeleted value is TRUE.
To restore the deleted AD user, right-click the object and click Modify.
The next step is to clear the value of the isDeleted attribute. Type isDeleted in the “Edit Entry Attribute” box, select the “Delete” operation and click Enter. The “[Delete]isDeleted:” operation has been added to the list.
The original parent container can usually be obtained from the lastKnownParent attribute of the deleted object. Next, you need to restore the original distinguishedName of the object. The original distinguishedName value should be “CN=USER NAME” + the value of the lastKnownParent attribute. So the restored DN should be:
Type “distinguishedName” in the “Edit Entry Attribute” box, paste the object’s original distinguishedName to the Values box and click Enter. Lastly, click Run. The output should show no errors if the operation went well.
Enable the account and reset the password so that the user can log in.
Note. Restoring a deleted user account without AD Recycle will not preserve most user settings. Only the original SID and the account name will be preserved. Most user attributes, properties, and group memberships will be lost. The most effective way to restore deleted AD object attributes in this case is by restoring the AD user from a previously created domain controller backup.
Restore Deleted AD Object Using ADRESTORE.EXE
Instead of the complex LDP.exe utility, you can use the lightweight Microsoft ADRESTORE tool to restore deleted objects more easily. ADRESTORE.exe is a command-line tool designed to find and restore “tombstoned” Active Directory objects.
Download the ADRESTORE tool and extract it to a local folder. In this example, I extracted the tool to C:\tools\ADRestore.
Open CMD or PowerShell and change the working directory to where you extracted the tool.
Run the adrestore64.exe command to list all the deleted AD objects. The command output includes all deleted AD objects, such as Organizational Units (OUs), users, computers, etc.
Or manually search for deleted objects matching the name John Doe: .\adrestore64.exe “John Doe”
In this example the command found one matching object.
Copy the object GUID from the previous step and run the below command to restore the deleted Active Directory user: .\adrestore64.exe -r {GUID}
Check that the user has been restored to the correct AD OU:
Get-ADUser -Identity jdoe
How to Restore Deleted Active Directory User from the Recycle Bin
Restoring a deleted user account is much easier if the Active Directory Recycle Bin is enabled in your domain. You can use the Active Directory Admin Center (GUI) or PowerShell commands.
Open the Active Directory Administrative Center using the command: dsac.exe
Navigate to Domain → Deleted Objects.
Select the deleted AD object from the list and click Restore. To restore deleted Active Directory users to a different OU, click “Restore To…” instead.
The deleted AD user has been restored to its original OU. You can now reset the password and enable the account.
Or you can restore deleted Active Directory user by using the Restore-ADObject cmdlet.
You can list all the deleted users in the Active Directory Recycle Bin:
The restored AD user is disabled. Enable it and reset the password before it can be used again. Keep in mind that when restored from the AD Recycle Bin, group memberships and most user attributes are preserved.
When a user account is deleted, Active Directory moves it to the hidden Deleted Objects container and sets the isDeleted attribute to True. By default, deleted objects remain recoverable for 180 days before being permanently removed by the AD garbage collection process.
In most environments, deleted objects can be restored within the 180-day tombstone lifetime period. If Active Directory Recycle Bin is enabled, recovery behavior may also depend on deleted object and recycled object retention settings.
The Active Directory Recycle Bin is a feature introduced in Windows Server 2008 R2 that allows administrators to restore deleted users, groups, and computer accounts while preserving most attributes and group memberships.
You can restore the user through the Active Directory Administrative Center (ADAC) by opening Deleted Objects and selecting Restore or Restore To. Alternatively, use the Restore-ADObject PowerShell cmdlet.
No. Without Recycle Bin, only basic information such as the original SID and account name is typically preserved. Most user attributes, settings, and group memberships are lost.
I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.
Hi Cyril,
Just to let you know that this article is very dell done and saved me a lot of time and effort.
Thank you,
Célio
You are welcome, Célio!