Active Directory Recycle Bin Feature In Windows Server 2012 R2

4234

Active Directory Recycle Bin Feature In Windows Server 2012 R2 In this post we will see Active Directory Recycle Bin Feature In Windows Server 2012 R2. If a system administrator working in Active Directory environment deletes any object in Active Directory by mistake, the effects of such mistakes can range from lost end-user productivity to broken network functionality. In Windows Server 2003 Active Directory and Windows Server 2008 AD DS, you could recover deleted Active Directory objects through tombstone reanimation. However, reanimated objects’ link-valued attributes (for example, group memberships of user accounts) that were physically removed and non-link-valued attributes that were cleared were not recovered. Therefore administrators could not rely on tombstone reanimation as the ultimate solution to accidental deletion of objects.

In Windows Server 2008 R2 there was a feature introduced called the Active Directory Recycle Bin to provide administrators with a way of recovering directory objects that were accidentally deleted. However, using the AD Recycle Bin in Windows Server 2008 R2 environments proved difficult for some administrators because enabling and using this feature could be performed only from the command-line, either by using the Ldp.exe utility or with Windows PowerShell cmdlets.

Windows Server 2012 R2 simplifies this task and makes it more easier for the administrators to recover deleted objects. Now you can use the GUI-based Active Directory Administrative Center for both enabling the AD Recycle Bin and recovering deleted objects. Before we do that lets understand about Active Directory object states.

When the AD Recycle Bin feature is enabled in an Active Directory environment, directory objects can be in one of the following four states :-

AD Recycle Bin Feature In Windows Server 2012 R2

1) Live Object – Suppose you create a user account for a user and the user is now logged in with this account. The user account is being used to log in to the computer or it is being used to access the resources from a network. This state of the object is known as Object Live state.

2) Deleted Object – When you delete an object from the Active Directory, it is moved to deleted objects container, but the object’s link-valued and non-link-valued attributes are still preserved. The object can be recovered by restoring it from the AD Recycle Bin (AD Recycle Bin feature should be enabled) if the lifetime of the deleted object has not yet expired. By default, the deleted object lifetime is configured as 180 days. If the object is in deleted state you can restore the object back to the Active Directory and the object goes to Live state.

3) Recycled Object– In this state the object remains in the Deleted Objects container, but most of its attributes are now stripped away. You cannot restore the object from the AD Recycle Bin or by taking other steps, such as reanimating Active Directory tombstone objects when the object is in recycled state.

4) Removed Object – Once the lifetime of a recycled object is expired, the AD garbage collection process starts by removing the remains of previously deleted objects from the database.

Enabling Active Directory Recycle Bin Feature In Windows Server 2012 R2

The Active Directory Recycle Bin feature is disabled by default in Windows Server 2012 R2. To enable the Active Directory Recycle Bin feature the forest functional level should be Windows Server 2008 R2 or higher. This means that all domain controllers in your forest must be running Windows Server 2008 R2 or higher. The process of enabling Active Directory Recycle Bin is irreversible, this means that once you enable the Active Directory Recycle Bin you cannot disable it.

To enable the Active Directory Bin Feature on Windows Server 2012 R2, log in with a user account that belongs to the Enterprise Admins or Schema Admins group. From the Server Manager, click on Tools and click Active Directory Administrative Center. Right click the target domain in the left navigation pane and click Raise the forest functional level.

AD Recycle Bin Feature In Windows Server 2012 R2

In the below example the Active Directory Forest Functional level is already Windows Server 2012 R2. You have to perform this task only if your organization forest functional level is lower than Windows Server 2008 R2.

AD Recycle Bin Feature In Windows Server 2012 R2

To check the current Forest functional level of your organization using powershell command, execute the below command in AD module for windows powershell.

Get-ADForest -Identity prajwal.local

AD Recycle Bin Feature In Windows Server 2012 R2

If you are looking to raise the forest functional level using powershell command, then launch Active Directory Module for Windows Powershell and execute the below command.

Set-ADForestMode 6 -Identity PRAJWAL.LOCAL (6 – If you want to raise the forest functional level to Windows Server 2012 R2)

Set-ADForestMode 5 -Identity PRAJWAL.LOCAL (5 – If you want to raise the forest functional level to Windows Server 2012)

Set-ADForestMode 4 -Identity PRAJWAL.LOCAL (4 If you want to raise the forest functional level to Windows Server 2008 R2)

AD Recycle Bin Feature In Windows Server 2012 R2

Right click on the target domain and click Enable Recycle Bin. On the confirmation box click OK.

AD Recycle Bin Feature In Windows Server 2012 R2

Click OK. On the top ribbon click on Refresh Icon.

AD Recycle Bin Feature In Windows Server 2012 R2

To enable the Active Directory Recycle Bin feature using Powershell command execute the code shown below in AD module for Windows Powershell

Enable-ADOptionalFeature –Identity ‘CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=prajwal,DC=local’ –Scope ForestOrConfigurationSet –Target ‘prajwal.local’

 

AD Recycle Bin Feature In Windows Server 2012 R2

To verify if the Recycle Bin feature is enabled or not, execute the below command

Get-ADOptionalFeature -filter *

 

AD Recycle Bin Feature In Windows Server 2012 R2

Now we see a new container called Deleted Objects under the target domain. When you delete any object from the Active Directory it moves to Deleted Objects container.

AD Recycle Bin Feature In Windows Server 2012 R2

Let’s create a test user named TempUser in the Users OU. Right click the newly created user and click on delete. When asked for confirmation to delete the user click Yes.

AD Recycle Bin Feature In Windows Server 2012 R2

To delete the user account from the Active Directorty, use the powershell command given below

Remove-ADUser -Identity TempUser

 

AD Recycle Bin Feature In Windows Server 2012 R2

First let us search for the object that has been deleted using powershell command.

Get-ADObject -SearchBase “CN=Deleted Objects,DC=prajwal,DC=local” -ldapFilter:”(msDs-lastKnownRDN=*)” – IncludeDeletedObjects –Properties lastKnownParent

 

AD Recycle Bin Feature In Windows Server 2012 R2

As said earlier in Windows Server 2012 R2, the Active Directory Recycle Bin feature has been enhanced with a new graphical user interface for users to manage and restore deleted objects. The deleted objects can now be seen in under Deleted Objects container. When you right click on the deleted object you see four options.

Restore – This option restores the deleted object to the location where it originally located before deletion.

Restore To – With this option you can restore the object to desired container.

Locate Parent – Shows the Container where the object was present before deletion. Use this option to know the original location of object before you use Restore or Restore To.

Properties – Displays the properties of the Object such as Name, Object Class, USN etc.

Right click the object present in the Deleted Objects container and click on Restore.

AD Recycle Bin Feature In Windows Server 2012 R2

We see that the user account is restored back to the original location using the Restore Option.

AD Recycle Bin Feature In Windows Server 2012 R2

To restore the deleted object back to the original location use the powershell command.

Get-ADObject -ldapFilter:”(msDS-LastKnownRDN=*)” –IncludeDeletedObjects | Restore-ADObject

 

AD Recycle Bin Feature In Windows Server 2012 R2

  • chetan

    hello prajwal it is amazing to watch your site and i am also working as SYS.admin in DC on win-server Can you kindly share me the win-server trouble shooting features .

  • Naveen Punj

    Nice post but I am bit confused on life cycle of an object in deleted state and recycle state. I assume it is 180 days in deleted items and 180 days in recycle bin which makes it 360 days by default ( changeable)
    Correct me if I am wrong…

  • Raj Verma

    Hello , Prajwal I am stillconfused with the SQl server compatibility with SCCM 2012 and 2012 R2…Could you please provide me the link that I can use to upgrade Sql server in order to install SCCM 2012 R2 on server 2012 R2