Appearance
Active Directory and LDAP
131. What is Microsoft Active Directory, and what problem does it solve?
The short answer
Active Directory, AD, launched with Windows 2000, is Microsoft's directory service for company networks. It keeps one central database of users, groups, computers and policies for an organisation, called a domain, and runs on servers called domain controllers. It solves the problem of managing thousands of people and machines one by one: an employee gets one account that logs in to any company PC, file share, printer and internal app, admins push settings to every machine through Group Policy, and disabling one account cuts off access everywhere on the network.
What AD bundles together:
| Part | Job |
|---|---|
| Directory database | Users, groups, computers, organisational units |
| LDAP | The protocol to query and change the directory |
| Kerberos | Logging in and SSO inside the network (the Kerberos question) |
| DNS | How machines find domain controllers |
| Group Policy | Pushing settings and security rules to every Windows machine |
| Replication | Keeping every domain controller's copy in sync |
Where it still matters. Most large companies still run AD for Windows PCs, file servers and older internal apps, usually connected to Microsoft Entra ID in the cloud. Attackers also target it heavily, because whoever controls AD controls the whole network.
132. What is LDAP, and what problem does it solve?
The short answer
LDAP, the Lightweight Directory Access Protocol, is an open, vendor-neutral protocol for reading and updating a directory: a database of people, groups and devices organised as a tree, built for many fast reads and few writes. It solves the problem of every application keeping its own user list: apps ask the central directory "does this user exist, what are their groups, is this their password?" over LDAP. It runs on TCP port 389, or 636 for LDAPS over TLS. Active Directory, OpenLDAP and many other directories speak it.
| Fact | Value |
|---|---|
| What it is | A protocol, not a product |
| Port | 389, with StartTLS; 636 for LDAPS |
| Data shape | A tree of entries, each with attributes |
| Main operations | Bind, search, compare, add, modify, delete |
| Common servers | Active Directory, OpenLDAP, FreeIPA, 389 Directory Server |
Always encrypt it. A plain LDAP bind sends the password across the network in clear text. Use LDAPS or StartTLS, and on Active Directory require LDAP signing and channel binding.
133. What is a directory service?
The short answer
A directory service is a specialised database that stores information about an organisation's people, groups, devices and resources, and answers questions about them quickly. It is like a phone book that systems consult: "who is asha?", "which groups is she in?", "where is the printer on floor 3?". It is tuned for many reads and few writes, organised as a hierarchy, replicated across servers for availability, and access-controlled. Active Directory, OpenLDAP and Microsoft Entra ID are directory services.
| Directory | General database | |
|---|---|---|
| Optimised for | Fast lookups, few changes | Mixed reads and writes |
| Shape | A tree of entries | Tables or documents |
| Typical data | People, groups, devices, policies | Orders, payments, anything |
| Schema | Shared, standard object types | Designed per application |
| Transactions | Limited | Full |
134. Explain LDAP architecture?
The short answer
LDAP uses a client-server model. Clients, such as apps, servers or login systems, open a TCP connection to a directory server and send operations: bind to authenticate, search, compare, add, modify, delete. The data is a tree called the Directory Information Tree. Each node is an entry, named by a distinguished name, holding attributes such as cn, mail and memberOf, and belonging to object classes such as user or group that the schema defines. Big directories split the tree across servers and replicate it for availability.
| Term | Meaning | Example |
|---|---|---|
| Entry | One node: a person, group or device | Asha's account |
| Attribute | A named value on an entry | mail, title, memberOf |
| Object class | The type, which decides allowed attributes | user, group, computer |
| Schema | All object classes and attribute definitions | Shipped with the server, extendable |
| DIT | The whole tree | Everything under dc=acme,dc=example |
135. What is a Distinguished Name (DN)?
The short answer
A distinguished name is the full, unique path of an entry in the LDAP tree, written from the entry itself up to the root, as comma-separated pieces. Asha's DN might be cn=Asha Rao,ou=People,dc=acme,dc=example: common name "Asha Rao", in the organisational unit "People", in the domain acme.example. Like a full postal address, no two entries have the same DN. It changes if the entry is renamed or moved, so applications should store a stable ID such as AD's objectGUID rather than the DN.
Reading a DN right to left, from the root:
| Piece | Type | Meaning |
|---|---|---|
dc=example | Domain component | Top-level domain |
dc=acme | Domain component | Together: acme.example |
ou=People | Organisational unit | A folder in the tree |
cn=Asha Rao | Common name | The entry itself |
Escaping matters. A comma inside a name, as in cn=Rao\, Asha, must be escaped, or it splits the DN in the wrong place. Use your LDAP library's DN functions, never string concatenation.
136. What is a Relative Distinguished Name (RDN)?
The short answer
The RDN is the first piece of a DN: the entry's own name, relative to its parent. In cn=Asha Rao,ou=People,dc=acme,dc=example, the RDN is cn=Asha Rao. It must be unique among siblings under the same parent, like a file name in a folder, but the same RDN can exist under different parents. The DN is the RDN plus the parent's DN. Renaming an entry means changing its RDN; moving it means changing its parent.
| RDN | DN | |
|---|---|---|
| Like | A file name | The full file path |
| Example | cn=Asha Rao | cn=Asha Rao,ou=People,dc=acme,dc=example |
| Unique within | One parent | The whole directory |
137. What is LDAP bind, and what is LDAP search?
The short answer
A bind is how a client authenticates to the LDAP server on a connection. A simple bind sends a DN and password; an anonymous bind sends nothing; a SASL bind uses another mechanism such as Kerberos. After a bind, the connection acts with that identity's permissions. A search asks the server for entries, with a base DN to start from, a scope of just that entry, one level or the whole subtree, a filter such as (&(objectClass=user)(mail=asha@acme.example)), and the attributes to return.
ts
import { Client, AndFilter, EqualityFilter } from 'ldapts'
const ldap = new Client({ url: 'ldaps://dc1.acme.example:636' }) // (1)
await ldap.bind('cn=svc-portal,ou=Service,dc=acme,dc=example', config.LDAP_PASSWORD) // (2)
const { searchEntries } = await ldap.search('ou=People,dc=acme,dc=example', { // (3)
scope: 'sub',
filter: new AndFilter({ filters: [
new EqualityFilter({ attribute: 'objectClass', value: 'user' }),
new EqualityFilter({ attribute: 'mail', value: email }), // (4)
] }),
attributes: ['dn', 'objectGUID', 'displayName', 'memberOf'], // (5)
})
await ldap.unbind()- LDAPS on port 636, so everything, passwords included, is encrypted.
- Bind as a service account with read-only rights.
- Search the People subtree.
- Build the filter with filter objects, which escape the value. Building
(mail=${email})as a string allows LDAP injection: an email of*)(objectClass=*would match everyone. - Ask only for the attributes you need.
LDAP filter syntax, read aloud:
| Filter | Means |
|---|---|
(mail=asha@acme.example) | Mail equals this |
(&(objectClass=user)(department=Finance)) | A user and in Finance |
(|(title=Manager)(title=Director)) | Manager or Director |
(!(userAccountControl:1.2.840.113556.1.4.803:=2)) | Not disabled, in AD |
(cn=Asha*) | Common name starts with Asha |
138. How does LDAP authentication work?
The short answer
An app checks a user's password against LDAP in two steps. First it binds as a service account and searches for the user by their login name or email, to find their DN. Then it opens a new connection, or rebinds, and does a simple bind as that user's DN with the password they typed. If the bind succeeds, the password is correct, and the app can read the user's groups. The app never sees the stored password; the directory checks it. This must run over LDAPS, and empty passwords must be rejected.
The empty-password trap. Many LDAP servers treat a simple bind with a DN and an empty password as an anonymous bind, and report success. An app that does not reject empty passwords first lets anyone log in as anyone. Always check password.length > 0 before binding.
Better options today. LDAP password checks mean your app handles the user's real password and cannot do MFA. Where possible, put the directory behind an identity provider and use OIDC or SAML instead.
139. What is the difference between Active Directory and LDAP?
The short answer
LDAP is a protocol: a standard language for talking to a directory. Active Directory is a product: Microsoft's directory service, which stores the data and also includes Kerberos, DNS, Group Policy and replication. AD speaks LDAP, so LDAP tools and apps can query it. Saying "AD versus LDAP" is like saying "a web server versus HTTP". AD also adds its own schema and extensions, such as sAMAccountName, objectGUID and userAccountControl, that a generic LDAP server would not have.
| LDAP | Active Directory | |
|---|---|---|
| Is | A protocol, a standard | A Microsoft product |
| Stores data | No | Yes |
| Authentication for Windows logins | No | Yes, through Kerberos |
| Policy management | No | Group Policy |
| Other implementations | OpenLDAP, FreeIPA and many more | Only Microsoft |
140. Does Active Directory use LDAP?
The short answer
Yes. LDAP is the main protocol for reading and changing Active Directory data. Domain controllers listen on port 389 for LDAP, 636 for LDAPS, and 3268 and 3269 for the Global Catalog, a searchable copy of key attributes from every domain in the forest. Windows itself, admin tools and countless apps use LDAP queries against AD. But Windows logins themselves use Kerberos, not an LDAP bind, and AD also uses DNS, RPC and SMB for other jobs.
| Port | Use |
|---|---|
| 389 | LDAP, with signing or StartTLS |
| 636 | LDAPS |
| 3268 / 3269 | Global Catalog / Global Catalog over TLS |
| 88 | Kerberos |
| 53 | DNS |
141. What is the difference between LDAP and Microsoft Entra ID?
The short answer
LDAP is a decades-old protocol for querying directories inside a company network. Microsoft Entra ID is a cloud identity service that does not speak LDAP at all by default. Apps talk to Entra ID with web protocols: OIDC and OAuth 2.0 for login and tokens, SAML for SSO, SCIM for provisioning, and Microsoft Graph, a REST API, for reading users and groups. To serve old apps that need LDAP, Microsoft offers a separate add-on, Entra Domain Services, which provides a managed LDAP and Kerberos domain.
| LDAP | Microsoft Entra ID | |
|---|---|---|
| Kind | Protocol | Cloud identity service |
| Where | Usually inside a private network | Internet, global |
| How apps log users in | LDAP bind with the password | OIDC, SAML redirects; MFA possible |
| How apps read users | LDAP search | Microsoft Graph REST API |
| MFA, Conditional Access | No | Yes |
142. What are the differences between on-premises Active Directory and Entra ID?
The short answer
On-premises AD runs on your own domain controllers, inside your network, and manages Windows PCs, servers and file shares with Kerberos, LDAP and Group Policy, in a tree of domains and organisational units. Entra ID is Microsoft's cloud service, run by Microsoft, which manages logins to cloud apps and Microsoft 365 with OIDC, OAuth and SAML, plus MFA and Conditional Access, in a flat tenant. They are not two versions of the same thing. Most companies run both, linked by Entra Connect, which syncs users from AD into Entra ID.
| Active Directory | Entra ID | |
|---|---|---|
| Runs | Your servers | Microsoft's cloud |
| Protocols | Kerberos, NTLM, LDAP | OIDC, OAuth 2.0, SAML, SCIM |
| Structure | Forests, domains, OUs | Flat tenant, groups, administrative units |
| Manages devices with | Group Policy | Intune |
| Login security | Password, smart card | MFA, passkeys, Conditional Access |
| Built for | Office network | Internet and cloud apps |
How cloud logins check an AD password, three options: password hash sync, where a hash of the AD password hash is synced to Entra ID and Microsoft recommends it; pass-through authentication, where an agent on-premises checks the password live; and federation through ADFS, an older approach Microsoft now advises moving away from.
143. What is a domain controller?
The short answer
A domain controller is a Windows Server that runs Active Directory Domain Services and holds a copy of the domain's directory database. It answers logins with Kerberos, serves LDAP queries, applies Group Policy, and usually runs DNS for the domain. A domain has several domain controllers that replicate changes to each other, so if one fails, others keep handling logins. Because it holds every account's password hashes, a domain controller is the most sensitive server in the company and must be protected accordingly.
What to remember about domain controllers:
| Topic | Fact |
|---|---|
| Replication | Multi-master: most changes can be made on any DC, then copied to the others |
| Read-only DC | A DC with no writable copy, for branch offices with weak physical security |
| FSMO roles | A few special jobs only one DC holds at a time, such as the schema master |
| Time | Kerberos needs clocks within 5 minutes, so the DCs are the time source |
| Attack target | A stolen DC database, NTDS.dit, gives every password hash |
Why attackers want one. With domain admin rights, an attacker can copy every password hash, or forge Kerberos tickets that let them act as anyone, the "golden ticket" attack. Protect DCs with separate admin accounts, tiered access, and close monitoring.