
Principal Advisor
Epical Sweden
Okay, I'd like to introduce Christoffer Andersson. Christoffer is the Principal Advisor at Epicel. I've known Christoffer for, probably 20 years or so, and he is probably the person who is most familiar with the internals of Active Directory of anyone, certainly anyone outside of Microsoft and quite possibly these days is more familiar than anybody inside Microsoft with the internals of Active Directory. And the talk today is Inside Active Directory Misconceptions, Myths, Bugs. So please give a warm welcome to Christoffer Andersson. So let's get started. Thank you for the introduction, Gil. So, yeah, basically, what I do during the days is that I work with Active Directory, PKI, security, doing tiering, pull ups, and all that kind of things. I'm also doing some some research, been able to find some security vulnerabilities in the past in Entra ID related to Entra ID and certificates. My two previous HIP Talks was also about PKI and vulnerabilities related to Active Directory used for privileged escalations. But I'm really a Directory Services AD geek, so going deep on behind the scenes and the internals of Active Directory is something that I really enjoy. So this session is gonna be not something really that you can take, go home directly, strike and implement. This is more like how things works behind the scene, how it can be used in unbalanced troubleshooting and so on. So we're gonna start with something simple as Admin SD holder that's been around in Active Directory since it was born basically. So I just want to see a few hands, how many knows Admin SD holder and what does? Okay. Quite a few people. So there have been some misconceptions there that Admin SD holder has been mixed up with something that's called SD prop. And even if you read a lot of articles out at Microsoft.com it still says that SD prop is actually the process behind admin SD holder and it's absolutely not. They are not related more than that admin SD holder in some scenarios actually sets a security descripton. It changes the ACLs on certain objects. So basically to describe ADMN SD holder very briefly, it just looks, it has like a template ACL and it goes through certain objects and see is the ACL on those objects, is it actually differencing from the template? And if it is differencing from the template, it applies the template ACL and turn off inheritance. But only if inheritance is disabled on the actual template. And it works if you're a member of a protected group and it protects all the members of the protected groups except two protected groups. And that is the domain controllers and read only domain controller groups. It only protects those groups, not the members of the groups. So I'm not going to go into Admin SD Holder more in detail. There is a guy that's called IMCora that's done an excellent write up in a I don't know how many pages, but there is a large PDF you can actually download on that subject. So I'm gonna actually go into what STProp does beyond actually propagating security descriptors because that's what it does. And the only thing that actually happens when the admin SD holder process runs, which is a completely other process, runs every hour on the PDCM later is that is in queues of propagation on the admin SD holder object itself even though it hasn't changed. And this happens every hour. And you can see that by looking into this attribute that's called the score propagation data. Unless there is the 14th bit of the heuristic set to one, then it's not going to even try the propagation. And SDPROP is not like some scheduled task, it's event driven when something in queues propagation because a write happens to the entity security descriptor attributes. So that is going to as the property is responsible for pushing that down the tree, and this happens individually on each domain controller. And it happened especially also on certain cases if you're going to if the RDN is reset, if the distinguished name is reset, if you lose your parent, your replication conflict or if there is a conflict between a reference phantom and a structural phantom, which we will go into later. So this is a little bit an introduction how Active Directory looks like in the database. So we can see that we have actually a flat table representing the hierarchy in the DIT. And this is made up with a primary key in the database, that's the D and T, distinguished name tag. You have the PD and T, which is the parent. And then you have this R and D type code, which tells if it starts with DC equals, O equals, CN equals and so on. So you can see that how that's actually you have Christoffer here and you see how that builds the hierarchy up here. And then we have another column in the date that's actually builds off the ancestry of every object and that store as ancestry column in there. And that is used for actually constructing subtree searches. We get support to subtree searches so you can select the range in there to actually target a certain subtree. So that's when you do a subtree search, that's how it works underneath, this is what's supported on the database layer. And this is actually responsibility of SDPROP as well to fix this up. So when you move an object around the DIT, then SDPROP comes in on every domain controller and actually do this. So the implementation looks like that you push like the SD's down and you also make sure that the ancestors are consistent. If they're not consistent, if there is so much work that the SDPROP cannot finish this or you should bound the DC before it has finished this, this can actually set a bit on that object to say that okay, the ancestry is inconsistent, that would signal this to the AD index optimization, and that would choose another index in the database to do the sub tree searches, and that will be much, much slower. So that's what actually do. And one thing that SDPROP also do is that it fixes object that has missed their grid. So if you have a grid less object, that's the third thing, that's also something that has to prompt us. So I'm gonna show that. So basically, we have some user here. We have Alf here. What's wrong with Alf? This poor user doesn't have any object grid. It's missing here. And we can use a route TSE mod that's called fix up inheritance and actually call ST prop to work on this object. But in order to do that we must have that D and T tag of that object. So in order to get that we need to run another route DC mod that we can actually use to get the D and T. And that's a ROTC model that's called dump references, and we need the distinguished name. Hit that in, run that, and then we go to entities folder and we get the file that's called entities. Ref. Dump. We open that up. And every object in the DIT is self reference itself. So you get D and T of that user here. So basically, what we're going to do now is that we're going to use that fix up inheritance route DC mod, and we need to have D and T colon to point out as the proper work on that object. And let's see. This from here. So we try to run that. Run that and. We should now. Have an event that's been logged on these DCs saying that the SDPROP has actually detected and done its work. It found that this object didn't have a grid. And if you now look in LDP, we can see that this object now actually has a grid. So that is how you can repair that if you encounter any objects that don't have a grid. And the caveat here is that this only works on objects that also have a SID. So it only works on security principle. And the reason for that, if you have two different DCs actually, I mean, as the prop run independently of them and they must come to the conclusion of setting the same quint on that object. So yes, reference integrity, I'm going to go through this pretty fast. So here is also how it's done under the covers. So the Entra Security Descriptor has a reference into the SD table. So you can also lose some of those references that will also corrupt the object. There is nothing we can do to repair this from the outside. You have to take down the database and run the entities util and the semantic database analyzer to actually fix this. So reference integrity and phantom. So basically reference integrity is objects in Active Directory that links to each other. They point out each other to the end syntax attributes. So there's different type of references, simple references, that's non linked attribute like see also you can put in another user there. You have manager where you point out another object. You have this gets more complicated when you go into cross ANSI references or cross database references where one of the NCs is not necessarily instantiated. What kind of this is that? Well, yes, this is DC, that's not also a global catalog. That is a question, is there anyone still have domain controllers that are not global catalog servers out there? Pretty much what I expected. So basically, this is how it can look like. For a simple reference, you have in the see also there, you can see that Lena is referencing Elena there. And to hold up that reference, it's actually that if you delete Elena no, sorry, yes, if you delete Elena, she's that record is never going to get removed from the database because that will leave a reference dangling there and that will be corrupt, the Elena object. So for simple references, you need to let go of that see also attribute. You need to clean it manually because otherwise it will never disappear from the DIT. The only thing that's going to happen is that it's going to be converted into a phantom. And you see the object column there is going to turn to zero and it's going to lose most of its attributes. Links is bit easier actually because you have the link table. And so here you can see that I'm a member of a group that's called ESE devs and then you can see how it's set up with the forward link and the backlink. So that's much easier. If you go across and see references, then that is more complicated because what's happened here is that those two objects are in different domains. So but this could still be on a global catalog or this is how it will look like on global catalog. You have just that is referencing Robin in the see also. And it becomes super complicated when you're speaking about non domain naming context like Forest DnS zones and domain DnS zones or if you have anything third party like application and sees. I'm not going to go through them, but there's a reason why they are there. And then it's got really, really messy on a machine that's not global catalog because if you have that reference, you need to build up everything that's needed to actually host DN for Robin here. So and there's a lot of rules here. I'm not going to go through them exactly. But this can go wrong. And looking at how this is how we can fix when references go wrong, we have an object here, this guy. So that doesn't look right. We cannot expand this object. And if we would try to open this object in AD users computers, AD users computers will hang and crash because this object is corrupted. We can get something out here because this error code here is easy or jet error code and it mean actually record not found. So something is wrong there. So we still need to I mean, we need to figure out the DN of the D and T of this object also to be able to work on this. And so we're going to dump the reference again for this subject just to get the D and T out. So if we now open this, got the distinguished name here. Now we need to do some other things. So we will use another route DC mode that's called dump database extended. Dump database has existed also since Windows 2000 and where you can dump the database to text file. Dump database extended allows us to actually do some other thing. I will put the exact encoding for those two bits here because you can use them in order what you want to do, what kind of index you want to be over. This is not known publicly or documented publicly anywhere else. So that was something I had to figure out myself. And then I have listed a lot of attributes here. And why are all of those attributes here? Well, because they are the in syntax attributes. And that's where I mean, if I have a reference integrity issue here, it's going to be in the syntax attributes. So basically, use this held up filter to gather that list. I will post everything of this on the blog as well if you want to go and play with it. So okay, we dumped the database. So this is we can see that we get the entire debt dumped here. You get the same thing here with D and T, PD and T and so on. But we need to convert that for easier processing. And we also want to sort of skip the first row steer. And we want to do a match here because we got that from the reference. So we know what, sorry, that was the problem. So yeah, so we know that this is the D and T. So we can actually go ahead and try to strip this out. And if we run that and if we open there we go. Yeah. So now we have that, you can see we have that specific object in there. And now we can actually go through here. This is gonna be manual like going through here and see what kind of object, what kind of reference could be bad. So we have see also 1996 there. You can see that there is a reference to that there is the self reference. You can see this is the object category, probably not going to be that one. And then you have to actually see what it can be. But we try this 1996 here. And what we can see here is that if we run a search for that, we don't get anything. But if you specifically so we would know there's no D and T starting with that. But if we search the entire data again, we only get that specific record. So this is a reference to something that only appears there. So this seems to be default the reference. So this can be repaired with the new route DC mod that's called check and fix the reference. And it can be run-in two modes. One will verify that this is broken, the other one will fix it. So let's let's try to run this one. So yeah, we run that and see if we've got anything here. Yeah, so this is actually then logged to the event log. It did confirm what we suspected that this is a broken reference. This doesn't exist in the D and T and it's, as it say, bad DIN reference to non existing object is found. So okay, we try to make this function fix the object for us. We switch the operation mode to fix by hitting one there and we run that. And we go here and see. We also have an event saying that this should now be sorry, here, this should not have been fixed. So basically, can we actually can we click on this object now? And now you see the object is repaired, so we don't get that error anymore. So now the object is back on track and that bad DN reference has been fixed locally. And this check and fix DN reference thing, it works in Windows Server 2025. It will work in 2022 and 2019, but Microsoft hasn't rolled that out. It will come in an upcoming patch like next month or the month after that. Okay. So some FSMO things that I mean, I think most people have pretty good idea what the five FSMO are doing. I mean, they've been there from the beginning as well. So we're going to look into like the infrastructure master. So the infrastructure master is pretty much responsible for keeping those references and the name of those references up to date. So but the question here is, is there even an infrastructure master today? The first question here is, of course, those non domain naming contexts have infrastructure masters. Sometimes when you run RD prep like RDCRDPrep, it's like saying that you don't the defismal role holder for your NDNCs could be like this and AD prep doesn't work. There is no infrastructure master for NDNCs. And when I say the rules are complicated for those references, those rules ensure that there can no be any references outside of what the local DC ever hosts. So there is no need for an infrastructure master for application NCs or NDNCs basically. But the question is, do we still have an infrastructure master for domains? So here we are looking at the case where we again have the same kind of reference thing here. And if you have a non GCDC that relies on the infrastructure master to get the name up to date. And so what the Infrastructure Mastery is that it actually validates all of the phantoms against the global catalog to make sure that everything is still in order. If anything has changed, then it's actually going to do those changes. It's going to ship those in an infrastructure update object with the DN reference update set to that object. So the new name or the change to that object is actually going to be pushed out to other non GCs in that domain. So that's how that's the sole purpose of the infrastructure master. And that's why also that couldn't rely on AGC because then there is nothing to scan. But here, how many of you have I take the question the other way around. How many of you have not turned on recycle bin? One, okay. So you still have an infrastructure master for your domain or domains. But actually if you don't, I mean if you have recycle bin on, then there is no infrastructure master anymore because every known DC is doing the work that the infrastructure master did. So this happens independently on each on DC, which gives us over to the next read fees per master, which is basically the read master. And everyone knows what the read master usually do, but it's also responsible for moving objects between domains if you have several domains within your forest. Many have multi domain forest still? Not so many, but still, yeah. Okay, so this is going to be a bit complicated, but bear with me. So how this works is actually that when you move an object from one domain to another, that can only be sourced on the read master. It can only happen on the read master. Must be the destination to ship the update. So what's happening? Well, that object is gonna be created in the target domain. But at the same time, in the source domain, there is an infrastructure update object that is created with proxy object name to the new DN in the new domain where the object were moved. This replicates all the other DCs and GCs in the source domain and actually converts that object to a phantom. And if you have a GIC that happens there too, then that GIC replicates with the domain or GIC of the target domain and that object gets promoted an object again with partial attribute set. But what happens if we move the read FSMO, we take another site into the scenario and we move the read FSMO and we move the same object here to another domain. This is disaster, right, because we are just moved the same object into two different domains simultaneously. And this cannot be this cannot happen. So when you move the read FSMO, you move those infrastructure master object with you in the same transaction as you move the read FSMO because otherwise, either replication latency could happen and that replicates in the infrastructure update, albeit replicates in too late when we've already been able to move off that. So the conclusion on this is that we if you're a recycle bin, you have no FSMO that used to create those infrastructure objects, well, it doesn't do it anymore. And the only role that I would just have is the RID master if you have a multi domain forest and you move objects across your mains. How many did run into this or did heard about that? If you had your schema FSMO role on Windows Server 2025 and you extended the schema for exchange, you would run into issues. I know a lot of people that actually did that full, fullest recovery to get out of this. And what happened was that replication was completely broken. You got into a schema conflict between your own other domain controllers, your level domain controllers. And this was something I wanted to look into, does this happen, what's wrong here. So basically what was wrong here was that attributes with a certain syntax string object identifier suddenly takes duplicates. So when you try to add in like the second attribute there, it should actually say that, sorry, already exists, you cannot duplicate here. And when you think about that, when you run LDFDE or the exchange scheme update, it's just going to try to append, it's just going to try to add and rely on that AD tells that, well, this is constraint, this is so it should look like this. So I started to go beyond the change. I created my own attribute for this. And that I run into the same issue. So this is beyond the change basically, and it's beyond schema. So then I started to look into, okay, it works as it should on Windows Server 2022, for example, and you get like an error out here when it says the value already exists. You can use that error code if you have a utility that calls this ID where you can actually calculate it also because this is something that the DS team at Microsoft have done really well. You can actually get out where is this hit in the source code. It's hitting that c file and then it hit on that line. So I could sort of figure out where is this actually coming from. So this actually, when it comes to duplicate detection, Active Directory has its own duplicate detection for attributes x, for Unicode attributes, but not for this one. They completely rely on EC or JET to do the duplicate detection. So when you call like, this is like how it looks like you're coming from LDAP to this AD, to this update, to something that's called DB at Atoll and then calls down to the CAB yet set column. And that has a flag that says that, okay, make sure that all the values are on queue in this column. So I think, okay, I take this to the next level. So I write some ECE code directly through the database and see what's happened then. And I set this bit here, see how that looks like. So here's my code, and you can see that it's the same thing. When I start 2005, I come through directly on the EC layer. Pre 2005 I get thrown out that I should. So this is actually not an Active Directory bug. And it only happens when the DIC is 32k pages. If it's eight ks pages, it doesn't happen. So it has not anything to do even with Windows R2005. So this turned out to be a 17 year old bug in EC. So even if you take the EC database on Windows two thousand and eight R2, you still hit this bug in EC. So this was how they resolved that. Speaking about bits and everything and the page size. So when do you really have an 8k page size date and when do you have a 32k size date? Well, it depends. For pre 2025, it's always 8k page size. It's always been like that, so Windows 2000. But 2005, it really depends. If you in place upgrade at the main controller, it's going to get stuck on 8k, even if it's Windows Server 2005. And if you EMF off that, it's going to still be on eight ks HP size. And this is important because you can never turn on the 32k page optional feature while you have those domain controllers. They need to get demoted. You need to get rid of them. So maybe you should have increased upgrade your Schema Master because that all that thing in the previous case relied on 32ks bit. If the Schema Master had been 8ks, you didn't have that exchange schema issue thing from the beginning. All other cases, it's 32ks page did. And you can look at that the page did with the SNT tool, if you want. Here is a tricky thing. So EC has this engine format version. You can think about that as like functional level for EC specific features. And the Active Directory team has decided to lock that down on a certain level. So for anything pre Windows 2000, it's 89.20 and for 2025, it's 96.00. And by default, it's that when you attach a JET database with ESD database, it's actually going to upgrade to the latest format. And you can see that next one, yes. So the thing that they missed here was that if you ever touched the database with Entity as Util and you had an 8ks page size database, they missed this and upgraded the database. And after that, Active Directory can no longer use the database because they lock on a specific lower version and the entity is util upgrades the database, so AD cannot use it anymore. And okay, so the Active Directory doesn't start anymore because it cannot attach the database. And what do you do when something doesn't work? Well, have you tried restarting it? If you try restarting it, the domain controller will never boot again. It's completely un bootable. There is no database corruption in there, though, but it cannot be used by Active Directory because it locks down a lower format there. So credentials in the D andT. This is kind of, well, overview of how it's done. You use the SIS key and the SIS key then encrypt something that's called PEC that is based on RSV4 pre Windows 2016 plus Windows 2016 is used by IES. And then you have some attributes that have an additional encryption with this based with the RID as the salt. And you can see it looks like this. If it's 2025, you have some additional hashes here that are not used, but they are there. They also actually stashed in RC4 here. And I have no idea why they have done that because this is exactly the same value as in Unicode PVD because it is the NTLM Hash that is used for RC4. So I'm going to have to wrap up. I'm going to try to do a last demo on prudent events related to credentials in the debt and RDCs. Yes. So here I'm using a tool that's called DS Internals. Anyone used DS Internals? Cool. So we're on RODC. And as you can see, this user has no secrets, no credential at all because this user is not allowed to cash its credential on RODC, all right? This user happens to be a domain admin. And so well, I cannot steal his secrets because it's very hard to steal something that doesn't exist, right? But well, what if we try to actually forge what we are want to steal in there. So we try to actually set the password for that account. This can take a little bit of time before. It's taking sometimes a little bit before it's actually yeah. And you can see that I'm domain admin now. So I actually took an account that absolutely has no secret on the RDC and I popped in my own secrets, used that and authenticated and become a domain admin. I can now take over everything in that branch locally that that RODC serves. So this is kind of important to think about. But still this is still I mean, already security model still are still in place because outbound replication is disabled, Kerberos key separation. I mean the RDTC has its own Kerberos key account. So I cannot go up with it that enterprise or domain admin account to the hub, but I can take everything in your local branch. So that is something that you should consider if you're still using RDCs and what you place in that local branch. So that's pretty much it. And there is one thing one more thing that you should consider also if you change I mean, if you disable any protocols like NTLM, RC4 and everything that's coming up, even if you have still have reversible encryption that you have your clear text password storing the DIT, so you untick that reversible encryption, that still stays in the D and T until you rotate your credentials. Always rotate the credential if you deprecate any protocols. Otherwise, they stay still in the D andT and the D and T will be like a dictionary to the real password through legacy protocols. So yes, that was pretty much it for me. I was going to post all like the demos and the scripts and everything on my blogs, so you can get it from there. So yes, so thank you so much for coming to listen.
Christoffer Andersson, a principal advisor at Epicel and Active Directory expert, delivers an in-depth technical presentation on the internal workings of Active Directory.
How does Active Directory really work? And which parts (spoiler: AdminSDHolder, SDProp, and Flexible Single Master Operation roles) don’t always work as expected?
Join this session for an investigation into—and demonstration of—some of the bugs that cause unexpected AD behavior in Windows Server environments. Learn hard-core Active Directory troubleshooting that can help you resolve real-world issues.

Principal Advisor
Epical Sweden
Thanks for subscribing!