Back in 2012 I was sure I’ve found a bug in Active Directory reference integrity and posted it to the activedir.org mailings list (that’s now history), hoping that some one who would understand what I’ve thought I’ve found and could sort of validated it, so I asked for someone that could potentially and ultimately give an answer – DonH him self and got an answer from him. If you don’t know who it is – have a look at this blog post from Joe Richards: joeware – never stop exploring… 🙂 » Blog Archive » History of Active Directory from someone who made it
From: activedir-owner@mail.activedir.org <activedir-owner@mail.activedir.org> On Behalf Of Don Hacherl
Sent: Monday, 22 October 2012 19:15
To: activedir@mail.activedir.org
Subject: RE: [ActiveDir] Structural Phantom becoming Reference Phantom at later stage and isn't improved by GUID and become "stale" forever.
It’s been so long since I looked at this, but your understanding sounds correct and the AD behavior sounds broken. When you added the second seeAlso value the DN should have been validated by the GC and improved with a GUID and then matched to the local structural phantom on D1-DC01. At this point (before the rename) you should be able to read the Christoffer Andersson object using the EXTENDED_DN control and see the GUID on the Accounts object DN value in the seeAlso.
Instead it sounds like a second phantom is being created for the Accounts object (bad!), and that this second phantom is not being improved with a GUID, and hence is not updated by the IM later.
The code to handle these cases was very subtle, and it was very easy to miss cases when making modifications to it. You should write up a report (be sure to include server OS versions and language settings) and submit it to Microsoft.
DonH
From: activedir-owner@mail.activedir.org [mailto:activedir-owner@mail.activedir.org] On Behalf Of Christoffer Andersson
Sent: Sunday, October 21, 2012 4:02 PM
To: activedir@mail.activedir.org
Subject: [ActiveDir] Structural Phantom becoming Reference Phantom at later stage and isn't improved by GUID and become "stale" forever.
Let’s say we have forest with two domains: D1 and D2.
There is one DC in both domains, the DC in D2 is also a GC, let call them:
D1-DC01
D2-GC02
Now let’s create the following objects within D2 at D2-GC02:
dn: ou=Accounts,DC=D2,DC=D1,DC=X
changetype: add
objectClass: organizationalUnit
dn: cn=Christoffer Andersson,OU=Accounts,DC=D2,DC=D1,DC=X
changetype: add
objectClass: user
Now let’s create the following object within D1 at D1-DC01
dn: cn=Lisa Andersson,cn=Users,DC=D1,DC=X
changetype: add
objectClass: user
seeAlso: cn=Christoffer Andersson,ou=Accounts,DC=D2,DC=D1,DC=X
Note: as D1-DC01 isn’t a GC a reference phantom is created for “Christoffer Andersson” as well a structural phantom for the “Accounts” OU to give “Christoffer Andersson” the full DN.
Now let’s reference the ”Accounts” OU directly:
dn: cn=Lisa Andersson,cn=users,DC=D1,DC=X
changetype: modify
replace: seeAlso
seeAlso: ou=Accounts,DC=D2,DC=D1,DC=X
seeAlso: cn=Christoffer Andersson,ou=Accounts,DC=D2,DC=D1,DC=X
Let’s trigger the IM to do some work:
dn:
changetype: modify
add: checkPhantoms
checkPhantoms: 1
I expected that the “Accounts” OU to be improved with a GUID? Or is this by design? (as it’s now referenced directly?)
Let’s say we rename the “Accounts” OU on D2 at D2-GC02 to “Accounts (CE-IT)” and back on D1-DC1 we trigger the IM again:
dn:
changetype: modify
add: checkPhantoms
checkPhantoms: 1
What would we see?
We would see this:
dn: cn=Lisa Andersson,cn=users,DC=D1,DC=X
seeAlso: ou=Accounts,DC=D2,DC=D1,DC=X
seeAlso: cn=Christoffer Andersson,ou=Accounts (CE-IT),DC=D2,DC=D1,DC=X
This is cause the “Accounts” OU wouldn’t have a GUID as it “was” a structural phantom to being with, and wasn’t improved with a GUID, hence it’s not on the PhantomIndex22 so the IM doesn’t care to maintain this phantom, however “Christoffer Andersson” has a GUID and is on the PhantomIndex22, so the IM determine that the DN has changed, but would create a “new!” structural phantom with the name “Accounts (CE-IT)” for the OU (again without GUID) to represent “Christoffer Andersson”’s full DN.
So what happens with the phantom for “Accounts”? Well since it is still referenced by the object “Lisa Andersson” and the ‘seeAlso’ attribute (even if the reference isn’t valid) it still gives the “accounts” phantom a +1 in the CNT_col making the Garbage Collector skipping over it every time? So basically the “Accounts” phantom will be stuck in the DIT at D1-DC01 forever until someone manually clear the reference in the ‘seeAlso’ attribute on “Lisa Andersson”
Just asking if this is by design? Hoping for DonH or something coming in to answer this
Okey so someone who really know confirmed my finding, so I brought it up with Microsoft and got a response it would not be fixed, sure enough there was likely other things that needed attention back in 2012.
It’s now 2026 and in an another discussion I brought this up with today’s ds team and got attention – this is really a bug – so let’s walk it through
Assume a forest with two domains – D1 (Root) and D2 (Child) – D1 contains a a GC (D1-GC1) and D2 contains a none-GC (D2-DC1)

Okey so now when we know the environment let’s implement some DN references between objects in the two domains using the ‘See-Also’ attribute as in the original example shared in the activedir.org mailing list.
Step 1:
We’re having a user in D2 (Lena Andersson) who references an object in D2 (DNRef) in her see-Also attribute as shown in the illustration below.

Step 2
Let’s now have another user in D2 (Elina Andersson) reference another object in D2 (GUIDLess) – but was this object is already represented in the D2-DC1’s NTDS.dit database as a structural phantom, it’s used, but not improved with a GUID (reference phantoms should have a GUID) – this is as mentioned below the core issue of this bug, full details are available below:

Step 3
Let’s now rename the object (GUIDLess) in D1 and strange things happens, but sort of to by design,
- Since GUIDLess remains a structural phantom by design by being just “GUIDLess” it’s never verified against a GC ever again, meaning it will be forever outdated on none-GCs in other domains where it has ever been referenced.
- In order to fulfill the requirement of reference integrity on DNRef that is a reference phantom (having a GUID) and build the correct and updated full DN in Lena Andersson’s ‘see-Also’ attribute (OU=DNRef,OU=GUIDLessChanged,DC=D1) a new structural phantom is created with the new name “GUIDLessChanged” and the “DNRef” reference phantom is reparented under it,
- However “Elina Andersson’s” ‘see-Also’ attribute will forever be stuck with an invalid DN that don’t exists in the forest any more “OU=GUIDLess,DC=D1”, until someone remove the DN reference explicitly or her object is recycled/tombstoned – full details are available below:

Fix 1:
This has now been fixed so when the structural phantom becomes referenced it also becomes upgraded to a real reference phantom, exactly the problem I spotted already back in 2012.
However there was something more that went wrong here because of another related bug, but I save the fun of that for Part 2 but I will leave a ESEDump output here, if you can spot what’s wrong:

I would like to thank Microsoft for once again listening to feedback and working with me on this one.
Note: Those fixes will make it to a future version of Windows Server and Active Directory and soon be a part of a Windows Server Insiders build.
