Active Directory: Domains, Objects and Groups
Almost every company that runs Windows manages its accounts, computers and policies with Active Directory. In an internal pentest it’s the playing field: the goal is usually to take over the domain, and getting there means knowing how to read it. The good news, if you’re the one auditing, is that any domain user can query most of the directory. This card is the vocabulary and the map; how each account authenticates comes in the next one.
Concepts
Section titled “Concepts”Workgroup vs. domain
Section titled “Workgroup vs. domain”| Workgroup | Domain | |
|---|---|---|
| Where accounts live | In each computer’s SAM | On the domain controller |
| Signing in | COMPUTER\user, on that computer only |
DOMAIN\user, on any joined computer |
| Policies | One machine at a time | Centralized with GPOs |
| Scale | A handful of computers | Thousands |
A domain has two names (the DNS name, pwnlab.local, and the NetBIOS name, PWNLAB) and a domain SID: every account SID in the domain starts with it and ends with its own RID.
What happens when a computer joins
Section titled “What happens when a computer joins”- The computer looks for a domain controller by asking DNS.
- A computer account is created (
WS01$, with a trailing$) with its own SID and password. The computer changes that password on its own, every 30 days by default. - The computer and the DC set up a secure channel using that password.
- The Domain Admins group is added to the computer’s local Administrators group.
The local SAM is still there: the computer keeps its local accounts and also accepts domain ones.
AD DS and the domain controller
Section titled “AD DS and the domain controller”AD DS (Active Directory Domain Services) is both the directory (the object database) and the service that manages it. The domain controller (DC) is the server that runs it: it holds the database and validates every sign-in. There are normally several DCs that replicate changes between them, so the domain keeps working if one goes down.
- NTDS.dit (
C:\Windows\NTDS\) is the database: every object and the hashes of every password in the domain. Each DC holds a copy. - SYSVOL and NETLOGON are DC shares holding GPOs and logon scripts. Any domain user can read them.
Objects, classes and attributes
Section titled “Objects, classes and attributes”Everything in AD is an object (a user, a computer, a group, an OU) of a class (user, computer, group), with attributes (description, memberOf, pwdLastSet, lastLogon…). The schema defines which classes and attributes exist, and there is only one per forest.
Most user and computer attributes can be read by any authenticated account. That’s why a single credential, however humble, is enough to map the whole domain.
An object’s names
Section titled “An object’s names”The same user has several names. Worked example with the account of Laura Gómez, from the finance department:
| Name | Value | What it’s for |
|---|---|---|
| DN (Distinguished Name) | CN=Laura Gómez,OU=Finanzas,DC=pwnlab,DC=local |
Its exact path in the directory (LDAP) |
| sAMAccountName | laura.gomez |
Classic logon name: PWNLAB\laura.gomez |
| UPN | laura.gomez@pwnlab.local |
Email-style logon name |
| objectSID | S-1-5-21-…-1107 |
The real identity: what ACLs use |
A DN is read right to left: in the pwnlab.local domain (DC=local, then DC=pwnlab), inside the Finanzas OU, the Laura Gómez object. If she’s moved to another OU, her DN changes; her SID doesn’t.
OUs, trees, forests and trusts
Section titled “OUs, trees, forests and trusts”- OU (organizational unit): a folder inside the domain to group objects, apply policies to them or delegate their administration.
- Tree: domains that share a namespace (
pwnlab.localandmadrid.pwnlab.local). - Forest: one or more trees with a common schema. It’s the real security boundary: inside a forest, whoever controls one domain can end up controlling the others.
- Trust: “A trusts B” means B’s users can access A’s resources. A trust can be one-way or two-way, and transitive (if A trusts B and B trusts C, A trusts C) or not. Between domains of the same forest, trusts are created automatically and are two-way and transitive.
flowchart TD
F["Forest pwnlab.local<br/>(one schema, security boundary)"] --> T1["Tree pwnlab.local"]
F --> T2["Tree pwnlab-lab.net"]
T1 --> D1["Domain pwnlab.local"]
T1 --> D2["Domain madrid.pwnlab.local"]
T2 --> D3["Domain pwnlab-lab.net"]
D1 --> O1["OU Finanzas"]
D1 --> O2["OU Servidores"]
O1 --> U1["user laura.gomez"]
O2 --> C1["computer SRV01$"]
A domain controller’s footprint
Section titled “A domain controller’s footprint”| Port | Protocol | What for |
|---|---|---|
| 53 | DNS | Resolving names and locating DCs |
| 88 | Kerberos | Issuing tickets; the one that gives a DC away |
| 135 | RPC | Remote administration (endpoint mapper) |
| 389 · 636 | LDAP · LDAPS | Querying the directory |
| 445 | SMB | SYSVOL, NETLOGON and file shares |
| 464 | kpasswd | Kerberos password changes |
| 3268 · 3269 | Global catalog (LDAP · LDAPS) | Forest-wide searches |
A machine with 53, 88, 389 and 445 open at the same time is almost certainly a DC.
AD doesn’t work without DNS
Section titled “AD doesn’t work without DNS”Computers don’t have their DC written down anywhere: they look it up in DNS through SRV records the DC publishes itself, such as _ldap._tcp.dc._msdcs.pwnlab.local or _kerberos._tcp.pwnlab.local. That’s why the DC is usually the domain’s DNS server too, and why a computer with the wrong DNS settings “can’t find the domain” even though it can reach the DC by IP.
Groups: type and scope
Section titled “Groups: type and scope”- Type: security groups (used to grant permissions) or distribution groups (mailing lists only; they don’t show up in the token).
- Scope:
| Scope | Who can be a member | Where it can be used |
|---|---|---|
| Domain Local | Accounts and groups from any trusted domain | Only in its own domain |
| Global | Accounts and global groups from its own domain | In any domain of the forest and in trusting domains |
| Universal | Accounts and groups from any domain in the forest | Across the whole forest |
Privileged groups
Section titled “Privileged groups”| Group | SID or RID | What it controls | On a Spanish-language Windows |
|---|---|---|---|
| Domain Admins | RID 512 | The whole domain | Admins. del dominio |
| Enterprise Admins | RID 519 (forest root only) | The whole forest | Administradores de empresas |
| Schema Admins | RID 518 (forest root only) | The schema | Administradores de esquema |
| Administrators | S-1-5-32-544 | The DCs | Administradores |
| Account Operators | S-1-5-32-548 | Creating and modifying many accounts | Opers. de cuentas |
| Backup Operators | S-1-5-32-551 | Reading any file on the DC, including NTDS.dit | Operadores de copia de seguridad |
The “delegated” groups (Account Operators, Backup Operators, Server Operators, DnsAdmins) look minor, but they’re often a shortcut to Domain Admins.
A GPO (Group Policy Object) is a set of rules defined once and applied automatically to computers and users: passwords, firewall, software, scripts, who is a local admin. GPOs are linked to sites, domains or OUs and applied in LSDOU order: local → site → domain → OU (from the outermost to the innermost). When two conflict, the last one applied wins, that is, the one linked to the OU closest to the object, unless a higher one is marked as enforced.
Computers re-read their GPOs every 90 minutes plus a random offset of up to 30 (DCs every 5). gpupdate /force applies them right away.
Entra ID is not Active Directory
Section titled “Entra ID is not Active Directory”Entra ID (formerly Azure AD) is Microsoft’s cloud directory: it works with OAuth, OpenID Connect and SAML, and has no OUs, no GPOs and no Kerberos as such. Most organizations today run hybrid setups, with on-premises AD synchronized to Entra ID. They share a brand name, not an architecture.
In practice
Section titled “In practice”These are all read-only commands, run from a domain-joined computer as a regular user.
:: Am I in a domain?systeminfo | findstr /B /C:"Domain" /C:"Dominio":: Domain: pwnlab.local <- WORKGROUP if not joined
:: Which DC am I using?nltest /dsgetdc:pwnlab.local:: DC: \\DC01.pwnlab.local:: Address: \\10.10.10.10:: Dom Name: pwnlab.local:: Forest Name: pwnlab.local
:: My full directory name (domain users only)whoami /fqdn:: CN=Laura Gómez,OU=Finanzas,DC=pwnlab,DC=local
:: Locate the DCs through DNSnslookup -type=SRV _ldap._tcp.dc._msdcs.pwnlab.local:: _ldap._tcp.dc._msdcs.pwnlab.local SRV service location::: priority = 0, weight = 100, port = 389:: svr hostname = DC01.pwnlab.local
:: Domain users and groupsnet user /domain:: One user: groups, last logon, expirynet user laura.gomez /domainnet group "Domain Admins" /domainWith the remote administration tools (RSAT) installed, the PowerShell module returns objects with all their attributes:
Get-ADDomain | Select-Object DNSRoot, NetBIOSName, DomainSIDGet-ADUser laura.gomez -Properties description, memberOf, pwdLastSet, lastLogonTimestampGet-ADGroupMember -Identity "Domain Admins" -Recursive | Select-Object Name, SamAccountNameNext offensive step
Section titled “Next offensive step”- Map the domain from an unprivileged user: AD enumeration and BloodHound.
- Abuse a GPO you can modify: GPO abuse.
- Jump between domains and forests: trust abuse.
Cheat sheet
Section titled “Cheat sheet”| Concept | What to remember |
|---|---|
| Domain | Administrative boundary, with a DNS name, a NetBIOS name and its own SID. |
| DC | Holds NTDS.dit and validates sign-ins. There are usually several. |
| Computer account | NAME$, password rotates by itself every 30 days. |
| DN | Directory path, read right to left. Changes if the object is moved. |
| sAMAccountName · UPN | PWNLAB\user · user@pwnlab.local. |
| objectSID | The real identity. |
| OU · container | An OU accepts GPOs; CN=Users doesn’t. |
| Forest | The real security boundary. |
| 53 + 88 + 389 + 445 | Almost certainly a DC. |
| SRV records | How computers find the DC. No DNS, no AD. |
| SYSVOL · NETLOGON | Readable by the whole domain. |
| Domain Local · Global · Universal | Where it’s used · who gets in · the whole forest. |
| LSDOU | Local → site → domain → OU. The closest wins, unless enforced. |
| GPO refresh | 90 min + up to 30 random. gpupdate /force. |
| Entra ID | Cloud directory, not AD. |
Review questions
Section titled “Review questions”-
You’re given the DN
CN=SRV-BACKUP,OU=Servidores,OU=Madrid,DC=pwnlab,DC=local. Where is the object?Answer
In the
pwnlab.localdomain, inside theMadridOU, and within it in theServidoresOU. The object is calledSRV-BACKUP. A DN is read right to left. -
Why is the forest, not the domain, said to be the security boundary?
Answer
Because the domains in a forest share a schema and automatic two-way transitive trusts, and there are groups with power over the whole forest (Enterprise Admins). Whoever controls one domain has paths to end up controlling the others in the same forest.
-
A machine has ports 53, 88, 389, 445 and 3268 open. What is it probably, and what does 3268 tell you?
Answer
A domain controller (88, Kerberos, is the biggest giveaway). Port 3268 means it’s also a global catalog, so it can answer searches about the whole forest.
-
A laptop reaches the DC by IP but “can’t find the domain” when trying to join. What do you check first?
Answer
The DNS server it’s using. Computers locate the DC through SRV records in the domain’s DNS; if the laptop uses another DNS server, it won’t find them even with IP connectivity.
-
Why is reading SYSVOL worth it as soon as you have the credentials of any domain user?
Answer
Because the whole domain can read it and it holds GPOs and logon scripts. If someone left a password or a sensitive setting there, anyone can get to it.
-
A domain GPO sets the wallpaper to blue and another one linked to the
FinanzasOU sets it to green. What does Laura, who’s in that OU, see?Answer
Green. GPOs are applied in local, site, domain and OU order, and in a conflict the last one wins, the one on the closest OU. She’d only see blue if the domain GPO were enforced.
-
What’s the difference between a security group and a distribution group?
Answer
A security group goes into its members’ token and is used to grant permissions; a distribution group only works as a mailing list: it has a SID too, but it doesn’t show up in the token, so it grants access to nothing.
References
Section titled “References”- Microsoft Learn — Active Directory Domain Services overview
- Microsoft Learn — Active Directory security groups (scopes and built-in groups)
- Microsoft Learn — How DNS support for Active Directory works (SRV records)
- Microsoft Learn — Group Policy processing (order and refresh)
- Microsoft Learn — ms-DS-MachineAccountQuota