Cloud Explainers

How Active Directory Works

Active Directory9 min videoPublished Nov 9, 2026

You sign in once at work and every computer and shared folder knows who you are; when someone leaves, IT switches them off everywhere at once. That's Active Directory. On a real Windows Server domain in our lab we make an account, see how a computer finds the domain controller through DNS, sign in with Kerberos tickets, watch a new group fail to reach a signed-in user until he signs in again, meet the password policy and Group Policy, and disable an account.

How Active Directory Works, the full picture: diagram of Ben's laptop, srv01, DNS, Kerberos, Directory, Group Policy, dc01: the domain controller
The whole picture, from the video's recap.

One password, every door

You sign in once at work, and every computer and shared folder already knows who you are. When someone leaves, I T switches them off everywhere at once. How? Ben, Ana's new hire at the tea shop, signs in to a shop computer he has never used. One password, and Windows already knows him: lab, backslash, ben, on srv01.

ben-laptop: Ben signed in to srv01 (over SSH)
ssh ben@lab.internal@srv01Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> whoamilab\ben
ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> hostnamesrv01

That's Active Directory. It does four jobs: a directory of every account, a way for computers to find it, sign-in tickets, and rules for every PC. And one change Ana makes for Ben doesn't reach him right away. We'll see which.

If it's always felt like magic, you're in good company. On Server Fault, the question 'What is Active Directory, and how does it work?' has over 331 thousand views. Let's answer it on a real domain.

Server Fault: 'What is Active Directory and how does it work?': figure of 331,257 views, source: api.stackexchange.com, question 402580, 2026-11-09

The directory

Where does Ben's account live? In a directory: one database of the organisation's users, groups and computers. It's kept on servers called domain controllers, and every computer in the domain asks them. Our lab's domain is lab.internal, with one domain controller, dc01.

One directory, kept on the domain controller: diagram of dc01, Users, Groups, Computers, domain: lab.internal

Why bother? Without a domain, every computer keeps its own list of users. Ben would need an account on each one, and a new password typed into each one. With Active Directory there's one account, one password, and when he leaves, one switch.

Every computer on its own, or one directory: comparison table of No domain vs Active Directory, Accounts, Password, Leaving

Ana, the shop's I T admin, works on that domain controller. She makes a folder for the shop, called an organisational unit, a group, Tea Shop Staff, and Ben's account, typing his first password once.

dc01: Ana's admin PowerShell
PS C:\TeaShop> New-ADOrganizationalUnit -Name TeaShop -Path 'DC=lab,DC=internal'
dc01: Ana's admin PowerShell
PS C:\TeaShop> New-ADGroup 'Tea Shop Staff' -GroupScope Global -Path 'OU=TeaShop,DC=lab,DC=internal'
dc01: Ana's admin PowerShell
PS C:\TeaShop> New-ADUser ben -GivenName Ben -Path 'OU=TeaShop,DC=lab,DC=internal' -AccountPassword (Read-Host -AsSecureString 'Password') -Enabled $truePassword:
***************

Here's Ben's entry. Enabled: true. A login name, ben, and a SID, a security ID: the number Windows really uses for Ben, so permissions follow him even if his name changes.

dc01: Ana's admin PowerShell
PS C:\TeaShop> Get-ADUser benDistinguishedName : CN=ben,OU=TeaShop,DC=lab,DC=internal
Enabled           : True
GivenName         : Ben
Name              : ben
ObjectClass       : user
ObjectGUID        : 49756274-7719-4b56-8f39-6284ab0213ac
SamAccountName    : ben
SID               : S-1-5-21-44274420-1659632989-1045501141-1135
Surname           :
UserPrincipalName :

That SID has parts too. S-1-5-21 says: an account made by a domain or a computer. The next three numbers identify the domain, lab.internal. And the last number is Ben's own, 1135, handed out by the domain controller and never reused.

Ben's security ID, in parts: diagram of S-1-5-21-44274420-1659632989-1045501141-1135, S-1-5-21 = a domain account, 44274420-1659632989-1045501141 = the domain, 1135 = Ben, Permissions store this number, not the name ben

His full name in the directory reads like an address, smallest part first. C N equals ben is the account. O U equals TeaShop is the shop's folder. And the two D C parts are the domain, lab dot internal.

Ben's full name in the directory: diagram of CN=ben,OU=TeaShop,DC=lab,DC=internal, CN=ben = the account, OU=TeaShop = the folder, DC=lab,DC=internal = the domain, Read it right to left: domain, folder, account

Computers are accounts too. srv01, the shop computer Ben signed in to, has its own entry in the Computers folder, made when it joined the domain. So the directory is a tree: the domain at the top, folders under it, and every user, group and computer in a folder.

The directory is a tree: diagram of lab.internal, OU=TeaShop, CN=Computers, ben, Tea Shop Staff, SRV01

Finding the domain controller

But how did the shop computer know where the domain controller is? It asked DNS, the network's phone book. Domain controllers list themselves there under service names, like: the el-dap service of lab.internal. el-dap is how programs read the directory. The answer is a name and a port, then the name becomes an address.

Asking DNS where the domain controller is: diagram of srv01, DNS on dc01, _ldap._tcp... lab.internal?, dc01.lab.internal, port 389, dc01.lab.internal?, 192.168.1.50, LDAP: how programs read the directory

Ben's Ubuntu laptop can ask the same question with dig. Its DNS server is the domain controller itself, as on most domain networks. S R V, for service: dc01, port 389. And dc01's address: 192.168.1.50. Ask a public DNS server instead, and the answer is NXDOMAIN: no such name.

ben-laptop: Ben's laptop
dig +short SRV _ldap._tcp.dc._msdcs.lab.internal0 100 389 dc01.lab.internal.
ben-laptop: Ben's laptop
dig +short dc01.lab.internal192.168.1.50
ben-laptop: Ben's laptop
dig SRV _ldap._tcp.dc._msdcs.lab.internal @1.1.1.1 | grep status;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 42534

That's a classic beginner trap. A computer that uses the router's or a public DNS server can't find the domain controller, so it can't join the domain or sign anyone in. lab.internal exists only in the domain's own DNS, which is why domain computers point their DNS at the domain controllers.

Ask the domain's DNS, not a public one: diagram of Ben's laptop, Public DNS, dc01's DNS

Signing in with tickets

Now the sign-in. Ben typed his password into srv01 once. srv01 doesn't send that password anywhere: it turns it into a key, and sends the domain controller proof made with it. The domain controller checks the proof against the directory, and hands back a ticket, the ticket-granting ticket. With that, srv01 asks for a ticket to each service Ben uses, without his password again. This is Kerberos.

Kerberos: proof once, then tickets: diagram of srv01, dc01, A service, I'm ben: proof, ticket-granting ticket, TGT: a ticket for this?, service ticket, The password never leaves srv01

klist shows Ben's tickets. The first is the ticket-granting ticket, issued by dc01. Guess first: how long is it good for? Ten hours. After that, srv01 needs a fresh one.

ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> klistCurrent LogonId is 0:0x35c3ed

Cached Tickets: (2)

#0>Client: ben @ LAB.INTERNAL
Server: krbtgt/LAB.INTERNAL @ LAB.INTERNAL
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
Ticket Flags 0x40e10000 -> forwardable renewable initial pre_authent name_canonicalize
Start Time: 11/9/2026 14:33:15 (local)
End Time:   11/10/2026 0:33:15 (local)
Renew Time: 11/16/2026 14:33:15 (local)
Session Key Type: AES-256-CTS-HMAC-SHA1-96
Cache Flags: 0x1 -> PRIMARY
Kdc Called: dc01.lab.internal

#1>Client: ben @ LAB.INTERNAL
Server: LDAP/dc01.lab.internal/lab.internal @ LAB.INTERNAL
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_delegate name_canonicalize
Start Time: 11/9/2026 14:33:15 (local)
End Time:   11/10/2026 0:33:15 (local)
Renew Time: 11/16/2026 14:33:15 (local)
Session Key Type: AES-256-CTS-HMAC-SHA1-96
Cache Flags: 0
Kdc Called: dc01.lab.internal

So far, two of the four jobs. Computers find the domain controller through DNS, and Kerberos turns one password into tickets, all checked against the same directory.

Groups open the doors

Who may open what? The shop's share on srv01 doesn't list people. Its folder lock names one group: Tea Shop Staff. Ana manages who's in the group, and the lock never changes.

The share trusts a group, not people: diagram of Ben, Tea Shop Staff, shop share, Ana

Ben isn't in it yet, so dir on the share says: access is denied. On the domain controller, Ana adds him to the group, and the group's member list shows ben.

ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> dir \\srv01\shopdir : Access to the path '\\srv01\shop' is denied.
At line:1 char:1
+ dir \\srv01\shop
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (\\srv01\shop:String) [Get-ChildItem], UnauthorizedAccessExc
   eption
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

Add-ADGroupMember, then Get-ADGroupMember, which lists one member: ben, a user.

dc01: Ana's admin PowerShell
PS C:\TeaShop> Add-ADGroupMember 'Tea Shop Staff' -Members ben
dc01: Ana's admin PowerShell
PS C:\TeaShop> Get-ADGroupMember 'Tea Shop Staff' | Format-Table Name, ObjectClassName ObjectClass
---- -----------
ben  user

Ben, still signed in, tries the share again. Guess first: does it open now? No. Still denied, with the same message. And whoami, asked for Ben's groups, finds no Tea Shop Staff at all, though the directory lists him.

ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> dir \\srv01\shopdir : Access to the path '\\srv01\shop' is denied.
At line:1 char:1
+ dir \\srv01\shop
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (\\srv01\shop:String) [Get-ChildItem], UnauthorizedAccessExc
   eption
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> whoami /groups | Select-String 'Tea Shop'

Here's why. When Ben signed in, Windows built him an access token: his SID, and the SIDs of every group he was in, at that moment. Every program he runs carries a copy, and the share checks the copy. Ana changed the directory, not the token Ben already holds.

Ben's access token, made when he signed in: diagram of lab\ben, Everyone, Authenticated Users, Tea Shop Staff?

So Ben signs out, and signs in again. New sign-in, new token: whoami now lists lab, Tea Shop Staff, and dir shows the shop's stock file.

ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> exitConnection to srv01 closed.
ben-laptop: Ben signed in to srv01 (over SSH)
ssh ben@lab.internal@srv01Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> whoami /groups | Select-String 'Tea Shop'LAB\Tea Shop Staff                         Group            S-1-5-21-44274420-1659632989-1045501141-1134
Mandatory group, Enabled by default, Enabled group
ben-laptop: Ben signed in to srv01 (over SSH)
PS C:\Users\ben> dir \\srv01\shop    Directory: \\srv01\shop


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         11/9/2026   2:33 PM             18 stock.txt

That's the change that doesn't reach Ben right away: a new group waits for his next sign-in. It catches everyone. A Server Fault question on forcing a group update without signing out has over 103 thousand views. The usual answer: sign out, and back in.

A new group waits for the next sign-in: cards of Ana adds Ben, Ben's token, 103k views, The fix

Rules in one place

The third job is rules. The domain's password policy lives on the domain controller: at least seven characters, with complexity on. So when Ana tries to give Ben the password tea1, the domain refuses it, for every computer at once.

dc01: Ana's admin PowerShell
PS C:\TeaShop> Get-ADDefaultDomainPasswordPolicy | Format-List MinPasswordLength, ComplexityEnabled, MaxPasswordAgeMinPasswordLength : 7
ComplexityEnabled : True
MaxPasswordAge    : 42.00:00:00
dc01: Ana's admin PowerShell
PS C:\TeaShop> Set-ADAccountPassword ben -Reset -NewPassword (ConvertTo-SecureString 'tea1' -AsPlainText -Force)Set-ADAccountPassword : The password does not meet the length, complexity, or history requirement of the
domain.
At line:1 char:1
+ Set-ADAccountPassword ben -Reset -NewPassword (ConvertTo-SecureString ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (ben:ADAccount) [Set-ADAccountPassword], ADPasswordComplexityExce
   ption
    + FullyQualifiedErrorId : ActiveDirectoryServer:1325,Microsoft.ActiveDirectory.Management.Commands.SetAD
   AccountPassword

Most other rules travel as Group Policy. Each policy is stored on the domain controller, in a shared folder called SYSVOL. Every computer in the domain reads the policies that apply to it, when it starts and when someone signs in. And the policies can be linked to a folder, like Ana's TeaShop, so they cover only what's in it.

Group Policy: rules every computer reads: diagram of dc01, srv01, Ben's sign-in

Ben can see that folder too. The first policy in it is the Default Domain Policy, which holds those password rules. And klist shows how he got in: a new service ticket, for the file service on dc01, with no password typed.

ben-laptop: on srv01; {31B2F340...} is the Default Domain Policy
PS C:\Users\ben> dir \\dc01\sysvol\lab.internal\Policies    Directory: \\dc01\sysvol\lab.internal\Policies


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/31/2026   3:44 PM                {31B2F340-016D-11D2-945F-00C04FB984F9}
d-----          9/1/2026   8:40 AM                {6AC1786C-016F-11D2-945F-00C04fB984F9}
ben-laptop: on srv01; {31B2F340...} is the Default Domain Policy
PS C:\Users\ben> klist | Select-String 'Server:'Server: krbtgt/LAB.INTERNAL @ LAB.INTERNAL
Server: krbtgt/LAB.INTERNAL @ LAB.INTERNAL
Server: cifs/dc01 @ LAB.INTERNAL

When someone leaves

The last job is the one I T loves. On Ben's last day, Ana switches off one account. Enabled: false.

dc01: Ana's admin PowerShell
PS C:\TeaShop> Disable-ADAccount ben
dc01: Ana's admin PowerShell
PS C:\TeaShop> Get-ADUser ben | Format-List Name, EnabledName    : ben
Enabled : False

Ben tries to sign in, and srv01 closes the connection before it even asks for his password.

ben-laptop: Ben's laptop
ssh ben@lab.internal@srv01Connection closed by 192.168.1.53 port 22

Connection closed. No tickets, no share. One switch in the directory, and every computer that checks the domain says no.

One switch, every door closed: diagram of ben, Sign-in to srv01, Tickets, shop share

Here's what happened. srv01 looks Ben up in the directory, finds his account switched off, and doesn't even ask for a password. A ticket he already held would still run out within hours, which is why an admin also signs out the open sessions of someone who's leaving.

One switch: the next sign-in is refused: diagram of Ben's laptop, srv01, dc01, sign in as ben, who is ben?, account disabled, connection closed, Old tickets run out: also sign out open sessions

Because everything asks the domain controllers, big companies run many, and they copy changes to each other. WIRED reported that the shipping company Maersk had about 150. When the NotPetya malware wiped its network in 2017, one domain controller survived, in Ghana, because a blackout had knocked it offline. Maersk rebuilt its directory from that one copy.

Maersk: about 150 domain controllers, one survivor: diagram of Domain controllers, NotPetya, 2017, One DC in Ghana

Recap

So: a directory of accounts, found through DNS, tickets instead of passwords, and rules for every computer. The lab and every command are linked in the description.

If Active Directory finally clicked, subscribing helps another beginner find it.

Every command here ran for real, on Windows Server in our own lab. Thanks for watching Cloud Explainers.

Sources

Demos: two Windows Server 2022 machines and an Ubuntu container in our own lab network; the OU, group, user and share were made for the video and removed afterwards; the tea shop is made up. Watch the full video on YouTube.

More videos

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Python9 min

Every Python Concept for Beginners in 10 Minutes

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio10 min

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python10 min

Python uv vs pip: Which One Should You Use?

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index