Skip to content
Pwnversity
FUND-AD-BASICSintermediate · 16 min · upd. 2026-11

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.

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.

  1. The computer looks for a domain controller by asking DNS.
  2. 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.
  3. The computer and the DC set up a secure channel using that password.
  4. 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 (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.

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.

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.

  • 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.local and madrid.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$"]
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.

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.

  • 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
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 (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.

These are all read-only commands, run from a domain-joined computer as a regular user.

Ventana de terminal
:: 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 DNS
nslookup -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 groups
net user /domain
:: One user: groups, last logon, expiry
net user laura.gomez /domain
net group "Domain Admins" /domain

With the remote administration tools (RSAT) installed, the PowerShell module returns objects with all their attributes:

Ventana de terminal
Get-ADDomain | Select-Object DNSRoot, NetBIOSName, DomainSID
Get-ADUser laura.gomez -Properties description, memberOf, pwdLastSet, lastLogonTimestamp
Get-ADGroupMember -Identity "Domain Admins" -Recursive | Select-Object Name, SamAccountName
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.
  1. You’re given the DN CN=SRV-BACKUP,OU=Servidores,OU=Madrid,DC=pwnlab,DC=local. Where is the object?

    Answer

    In the pwnlab.local domain, inside the Madrid OU, and within it in the Servidores OU. The object is called SRV-BACKUP. A DN is read right to left.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. A domain GPO sets the wallpaper to blue and another one linked to the Finanzas OU 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.

  7. 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.