0Pricing
Cloud & IT Cert Prep · Lesson

Directory Services: LDAP and Active Directory

Understand how LDAP directories and Active Directory organize users, groups, and computers, and how Group Policy enforces security settings at scale.

Directory Services: LDAP and Active Directory is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Are Directory Services?

A directory service is a centralized repository that stores and organizes information about network resources — users, groups, computers, printers, and policies. Rather than maintaining separate user databases on every system, organizations use a directory service as the single source of truth for identity information. All authentication requests are validated against the directory, and access policies are enforced consistently across the enterprise.

LDAP: Lightweight Directory Access Protocol

LDAP (Lightweight Directory Access Protocol) is the industry-standard protocol for querying and modifying directory services. LDAP organizes entries in a hierarchical tree called the Directory Information Tree (DIT), with entries identified by a Distinguished Name (DN). LDAP runs on port 389 (cleartext) and port 636 (LDAPS — LDAP over TLS). LDAP is the protocol; the directory itself is a separate product.

# LDAP Distinguished Name structure
cn=John Smith,ou=Engineers,dc=corp,dc=example,dc=com

# cn  = Common Name (user's name)
# ou  = Organizational Unit
# dc  = Domain Component

# LDAP search query example
ldapsearch -H ldap://dc.corp.example.com \
  -b 'dc=corp,dc=example,dc=com' \
  '(sAMAccountName=jsmith)' mail memberOf

Active Directory Architecture

Active Directory (AD) is Microsoft's enterprise directory service, built on LDAP and Kerberos. It organizes resources into Domains, which group into Trees, which group into Forests. A domain controller (DC) hosts the AD database (NTDS.dit) and handles authentication. AD is the backbone of identity management in most Windows enterprise environments.

# Active Directory hierarchy
# Forest: corp.example.com (trust boundary)
#   Tree: corp.example.com
#     Domain: corp.example.com
#       OU: Engineering
#         User: jsmith
#         Group: Dev-Team
#       OU: Finance
#         Computer: FIN-PC-01

Kerberos Authentication in Active Directory

Active Directory uses Kerberos as its default authentication protocol. The process works through ticket-granting: the client authenticates to the Key Distribution Center (KDC) and receives a Ticket-Granting Ticket (TGT). When the user needs to access a resource, they present the TGT to get a Service Ticket for that specific resource. Passwords are never sent over the network — only encrypted tickets. This design is central to understanding attacks like Kerberoasting.

# Kerberos authentication flow (simplified)
# 1. Client -> KDC: Authentication Request (AS-REQ)
# 2. KDC  -> Client: Ticket-Granting Ticket (AS-REP)
# 3. Client -> KDC: Service Ticket Request (TGS-REQ) + TGT
# 4. KDC  -> Client: Service Ticket (TGS-REP)
# 5. Client -> Server: Access Request + Service Ticket
# 6. Server validates ticket -> Access granted

Group Policy Objects (GPOs)

Group Policy Objects (GPOs) are AD's mechanism for enforcing security settings across thousands of machines simultaneously. GPOs can configure password complexity requirements, screen lock timeouts, software installation, firewall rules, and registry settings. GPOs are linked to AD containers (sites, domains, OUs) and apply to all users and computers within that container. GPO settings are refreshed every 90 minutes by default, ensuring compliance is maintained even on machines that drift from policy.

# Common GPO security settings
# Computer Configuration -> Windows Settings -> Security Settings:
#   Password Policy:
#     - Minimum password length: 14
#     - Password complexity: Enabled
#     - Maximum password age: 90 days
#   Account Lockout Policy:
#     - Lockout threshold: 5 attempts
#     - Lockout duration: 30 minutes

AD Security Groups and Least Privilege

Active Directory uses Security Groups to manage access permissions collectively. Instead of assigning permissions to individual users, administrators grant permissions to groups and add users to appropriate groups. Key built-in groups to understand for Security+: Domain Admins (full domain control), Enterprise Admins (forest-wide control), Schema Admins (modify AD schema), and Administrators (local machine admin). Membership in these high-privilege groups must be tightly controlled.

LDAP Injection Attacks

LDAP injection is the directory services equivalent of SQL injection. An attacker manipulates an LDAP query by inserting special characters (*, (, ), \, NUL) into user input that is concatenated directly into an LDAP filter. A successful attack can bypass authentication, extract all directory entries, or modify directory objects. Prevention requires input validation and using parameterized LDAP APIs rather than string concatenation.

# Vulnerable LDAP filter (DO NOT use)
filter = '(uid=' + user_input + ')'
# Attacker input: *)(&
# Result: (uid=*)(&) -- returns ALL users

# Defense: escape special chars before including in filter
# LDAP special chars: ( ) * \ NUL
# Use LDAP library escaping functions

AD Replication and Domain Controllers

Enterprises deploy multiple domain controllers for redundancy and geographic distribution. AD replication keeps all DCs synchronized using the Directory Replication Service (DRS). Attackers exploit replication for the DCSync attack — using replication permissions to request all password hashes from a DC without actually logging on to it. Protecting replication permissions is a critical AD hardening step.

# DCSync attack detection query (PowerShell)
# Detect accounts with dangerous replication permissions:
Get-ObjectAcl -DistinguishedName 'DC=corp,DC=example,DC=com' |
  Where-Object { $_.ActiveDirectoryRights -match 'DS-Replication' } |
  Select-Object IdentityReference, ActiveDirectoryRights

Securing LDAP: LDAPS and Signing

Plain LDAP on port 389 transmits data — including bind credentials — in cleartext, making it vulnerable to interception. Organizations should enforce LDAPS (LDAP over TLS) on port 636 to encrypt all directory traffic. Additionally, LDAP signing and channel binding should be required to prevent relay attacks where an attacker intercepts and replays LDAP authentication messages to gain unauthorized access.

# Verify LDAP signing requirement (Windows)
# Registry key:
# HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Parameters
# LDAPServerIntegrity = 2 (Require signing)

# Or via GPO:
# Security Settings -> Local Policies -> Security Options
# 'Domain controller: LDAP server signing requirements' = Require signing

AD Attack Surface: Common Misconfigs

Active Directory environments accumulate misconfigurations over years of operation. Common AD security weaknesses include: unconstrained delegation (allows impersonation of any user), Kerberoastable service accounts with weak passwords, AS-REP roasting targets (accounts with pre-authentication disabled), excessive Domain Admin membership, and AdminSDHolder misconfigurations that grant hidden elevated permissions. Regular AD security assessments using tools like BloodHound help identify these paths.

LDAP vs Active Directory Summary

To clarify the relationship: LDAP is the protocol used to communicate with directories (like HTTP is used to communicate with web servers). Active Directory is Microsoft's directory service product that uses LDAP as its access protocol. Other LDAP-compatible directories include OpenLDAP (open source), Oracle Directory Server, and Red Hat Directory Server. All use LDAP queries but have different management interfaces and additional proprietary features.

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: LDAP is the protocol for querying directory services using Distinguished Names in a hierarchical tree, Active Directory uses Kerberos for authentication and GPOs to enforce security settings across domains, and LDAPS on port 636 and LDAP signing should be required to prevent interception and relay attacks. Next up we explore Privileged Access Management (PAM).

Frequently asked questions

Is the “Directory Services: LDAP and Active Directory” lesson free?

Yes — the full text of “Directory Services: LDAP and Active Directory” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Directory Services: LDAP and Active Directory”?

Understand how LDAP directories and Active Directory organize users, groups, and computers, and how Group Policy enforces security settings at scale. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Directory Services: LDAP and Active Directory” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Directory Services: LDAP and Active Directory
  2. Privileged Access Management (PAM)
  3. Identity Governance and Provisioning
  4. Just-in-Time Access and Conditional Access Policies
← Back to Cloud & IT Cert Prep