Active Directory Fundamentals
What is Active Directory?
Active Directory (AD) is Microsoft’s directory service for Windows Domain environments. It serves as the centralized identity and access management backbone for the vast majority of enterprise networks.
Core Characteristics
- Centralized Database: Stores information about network resources and identities in a single, authoritative source.
- Hierarchical Structure: Organizes objects in a tree-like directory partition.
- Scalability: Manages users, computers, groups, and policies across thousands of machines.
- Prevalence: Powers 90%+ of enterprise Windows environments worldwide.
Key Functions
| Function |
Description |
| Authentication |
Verifies user and computer identities via Kerberos/NTLM |
| Authorization |
Controls access to resources via group membership and ACLs |
| Centralized Management |
Deploy policies (GPOs), software, and configurations at scale |
| Name Resolution |
Integrates with DNS for service location |
| Replication |
Distributes data across multiple Domain Controllers |
Why AD Matters for OSCP
Active Directory is arguably the most important topic for the OSCP exam. Here’s why:
| Reason |
Explanation |
| Lab Prevalence |
Most OSCP labs contain AD domains. At least one machine will be domain-joined, and many labs have full AD environments. |
| Rich Attack Surface |
AD exposes multiple attack vectors: authentication protocols (Kerberoasting, AS-REP Roasting), trust relationships, GPO misconfigurations, ACL abuses, and delegation vulnerabilities. |
| Pivoting Hub |
AD is the central pivot point for lateral movement. Compromising one domain-joined host often gives you a foothold to attack the entire domain. |
| Domain Admin = Game Over |
Gaining Domain Admin (DA) privileges effectively means owning the entire domain — all machines, all users, all data. |
| Real-World Relevance |
AD penetration testing is the most common enterprise pentest scenario. OSCP tests skills directly transferable to professional engagements. |
OSCP Exam Reality Check
In the OSCP exam, you will encounter at least one Active Directory environment. The ability to enumerate, analyze, and exploit AD misconfigurations is often the difference between passing and failing. Many exam machines require AD-based privilege escalation paths (ACL abuse, GPO exploitation, delegation attacks) to reach Domain Admin.
Directory Services Concept
A directory service is a specialized database designed specifically for storing and retrieving information about network objects. Unlike traditional relational databases (optimized for writes and transactions), directory services are optimized for read-heavy workloads.
Directory Service Characteristics
Directory Service Characteristics:
├── Read-optimized (not write-optimized)
│ └── Fast lookups, slow bulk modifications
├── Hierarchical organization
│ └── Tree structure (not flat tables)
├── Schema-defined object types
│ └── Predefined classes (user, group, computer, etc.)
├── Replication across controllers
│ └── Multiple DCs maintain consistent copies
├── Supports distributed queries
│ └── Search across the entire directory tree
└── Integrates with authentication protocols
└── Kerberos, NTLM, LDAP bind
How AD Differs from Relational Databases
| Feature |
Relational DB (SQL) |
Directory Service (AD) |
| Optimization |
Write-heavy, transactions |
Read-heavy, lookups |
| Structure |
Tables, rows, columns |
Tree, objects, attributes |
| Schema |
Flexible, user-defined |
Strict, predefined classes |
| Replication |
Master-slave or peer-to-peer |
Multi-master, automatic |
| Query Language |
SQL |
LDAP filters |
| Use Case |
Applications, data storage |
Identity, authentication, policy |
LDAP Protocol
LDAP (Lightweight Directory Access Protocol) is the primary protocol for communicating with Active Directory. Defined in RFC 4510-4519, it is the language you will use most frequently during AD enumeration.
Protocol Basics
| Property |
Value |
| Protocol |
Application layer (OSI Layer 7) |
| Transport |
TCP |
| Default Port |
389 (unencrypted) |
| Secure Port |
636 (LDAPS with TLS) |
| Global Catalog |
3268 (unencrypted), 3269 (LDAPS) |
| Model |
Client-server |
LDAP Key Concepts
| Concept |
Description |
Example |
| DN (Distinguished Name) |
Full unique path to an object in the directory tree |
CN=John Smith,OU=Sales,DC=corp,DC=local |
| RDN (Relative DN) |
The name component at one level of the hierarchy |
CN=John Smith |
| Schema |
Defines which object classes exist and what attributes they can have |
user, group, computer, organizationalUnit |
| Base DN |
The starting point for searches |
DC=corp,DC=local |
| Attributes |
Properties/key-value pairs) |
sAMAccountName, mail, description |
| Object Class |
Template that defines what attributes an object can have |
person, organizationalPerson, user |
LDAP DN Structure Breakdown
CN=John Smith,OU=Sales,OU=Users,DC=corp,DC=local
│ │ │ │ │
│ │ │ │ └── Domain Component (local)
│ │ │ └── Domain Component (corp)
│ │ └── Organizational Unit (Users)
│ └── Organizational Unit (Sales)
└── Common Name (John Smith)
DN Components:
| Component |
Prefix |
Used For |
| Common Name |
CN |
Users, groups, computers, GPOs |
| Organizational Unit |
OU |
Containers for organizing objects |
| Domain Component |
DC |
Domain name parts |
| Container |
CN |
System containers (e.g., CN=Users) |
LDAP Attribute Types
| Type |
Description |
Examples |
| Single-valued |
Object can have only one value |
sAMAccountName, objectClass, distinguishedName |
| Multi-valued |
Object can have multiple values |
member, memberOf, proxyAddresses, servicePrincipalName |
| Constructed |
Computed from other data (not stored directly) |
memberOf (computed by reading group member attributes) |
| Operational |
Maintained by the system, not user-settable |
whenCreated, uSNChanged, lastLogonTimestamp |
Essential LDAP Attributes for Enumeration
These are the attributes you must know for OSCP. Each one can reveal attack opportunities.
| Attribute |
Description |
Attack Relevance |
sAMAccountName |
Pre-Windows 2000 logon name (e.g., jsmith) |
Identify valid accounts for password spraying, brute force |
userPrincipalName |
UPN for logon (e.g., jsmith@corp.local) |
Used for Kerberos TGT requests, often differs from sAMAccountName |
description |
Free-text description field |
Frequently contains passwords left by administrators. Always check! |
unicodePwd |
Password attribute (write-only) |
Password reset attacks when you have write access to a user object |
servicePrincipalName |
SPN for Kerberos service identification |
Kerberoasting targets — any user with an SPN can have their TGS ticket requested and cracked offline |
pwdLastSet |
Timestamp of last password change |
Identify stale passwords (never changed = likely weak or reused). Value of 0 means password must be changed at next logon |
lastLogon |
Last login time (not replicated, DC-specific) |
Identify active vs. dormant accounts. Check each DC separately |
lastLogonTimestamp |
Last login time (replicated, ~14 day delay) |
Quick way to identify active accounts across all DCs without querying each one |
userAccountControl |
Bitmask of account flags |
Identify enabled/disabled accounts, delegation settings, pre-auth requirements (see UAC flags below) |
msDS-AllowedToActOnBehalfOfOtherIdentity |
RBCD delegation attribute |
Resource-Based Constrained Delegation — if you can write this attribute on a computer object, you can gain admin access to that machine |
msDS-GroupMSAMembership |
Managed Service Account membership |
Identifies gMSA usage, which has security implications |
displayName |
Display name |
Information gathering, social engineering |
mail |
Email address |
Information gathering, phishing targets |
title |
Job title |
Identify high-value targets (admins, executives) |
department |
Department name |
Map organizational structure |
memberOf |
Groups the object belongs to |
Identify privileged group membership, attack paths |
primaryGroupID |
Primary group RID |
RID 516 = Domain Controllers, RID 513 = Domain Users |
badPasswordTime |
Last bad password attempt timestamp |
Detect ongoing brute force attempts |
lockoutTime |
Account lockout timestamp |
0 = not locked out. Non-zero = locked (value is timestamp) |
doesNotRequirePreAuth |
Kerberos pre-authentication disabled |
AS-REP Roasting target when true |
passwordNotRequired |
Account can have empty password |
Trivial to exploit if account is enabled |
trustedForDelegation |
Account is trusted for delegation |
Unconstrained delegation attack target |
trustedToAuthForDelegation |
Account can be used for protocol transition |
S4U2Self/S4U2Proxy attack target |
UserAccountControl (UAC) Flags Quick Reference
The userAccountControl attribute is a bitmask. Each bit represents a different account property. You can calculate which flags are set by decomposing the value.
| Flag |
Value (Decimal) |
Meaning |
Attack Relevance |
NORMAL_ACCOUNT |
512 |
Standard user account |
Baseline — most accounts |
DONT_EXPIRE_PASSWORD |
65536 |
Password never expires |
High-value target — stale credentials, likely weak |
NOT_DELEGATED |
1048576 |
Account cannot be delegated |
Blocks delegation-based attacks |
USE_DES_KEY_ONLY |
2097152 |
Forces DES encryption for Kerberos |
Weak encryption — easier to crack |
DONT_REQ_PREAUTH |
4194304 |
Kerberos pre-authentication not required |
AS-REP Roasting target |
TRUSTED_FOR_DELEGATION |
524288 |
Unconstrained delegation enabled |
Delegation attack target |
TRUSTED_TO_AUTH_FOR_DELEGATION |
1073741824 |
Protocol transition enabled |
S4U2Self/S4U2Proxy attack target |
SENSITIVE_ACCOUNT |
524288 |
Protected from delegation |
Defense indicator — blocks delegation |
PASSWORD_NOT_REQUIRED |
32 |
Account can have empty password |
Trivial to exploit |
ACCOUNTDISABLE |
2 |
Account is disabled |
Cannot be used for authentication (but can still be abused via ACL) |
Calculating UAC — Example
Example: UAC = 593920
Step 1: Find the largest flag that fits
593920 - 524288 (TRUSTED_FOR_DELEGATION) = 69632
69632 - 65536 (DONT_EXPIRE_PASSWORD) = 4096
4096 - 512 (NORMAL_ACCOUNT) = 0
Result: 593920 = 512 + 65536 + 524288
→ Normal account, password never expires, unconstrained delegation enabled
This is a HIGH-VALUE target for OSCP:
1. Password never expires → likely weak/stale
2. Unconstrained delegation → can capture TGTs of any user who accesses this machine
LDAP Search Filters
Understanding LDAP filters is essential for enumeration. Here are the most important filter patterns:
| Filter |
Description |
(objectClass=*) |
Return all objects |
(objectClass=user) |
Return all user objects |
(objectClass=group) |
Return all group objects |
(objectClass=computer) |
Return all computer objects |
(sAMAccountName=jsmith) |
Find specific user |
(description=*password*) |
Find objects with “password” in description |
(servicePrincipalName=*) |
Find all objects with SPNs (Kerberoasting targets) |
(userAccountControl:1.2.840.113556.1.4.803:=524288) |
Bitwise AND for unconstrained delegation |
(userAccountControl:1.2.840.113556.1.4.803:=4194304) |
Bitwise AND for no pre-auth (AS-REP Roasting) |
(!primaryGroupID=516) |
Exclude domain controllers |
(whenCreated>=20240101000000.0Z) |
Objects created after a date |
OSCP Exam Checklist: AD Fundamentals
Must-Know Concepts
Must-Remember Commands
# Anonymous LDAP enumeration
ldapsearch -x -h DC_IP -b "DC=domain,DC=com" "(objectClass=user)" sAMAccountName description servicePrincipalName
# Authenticated LDAP enumeration
ldapsearch -x -H ldap://DC_IP -D "user@domain.com" -w password \
-b "DC=domain,DC=com" "(objectClass=*)"
# Query Global Catalog for forest-wide search
ldapsearch -x -H ldap://DC_IP:3268 -D "user@domain.com" -w password \
-b "DC=domain,DC=com" "(objectClass=*)"