# 轻量级目录访问协议

**轻量级目录访问协议**（Lightweight Directory Access Protocol，LDAP）是一种用于查询和修改目录服务的应用协议。目录服务是存储用户与账户信息以及密码等安全数据、并与网络上其他设备共享这些信息的网络服务。电子邮件、客户关系管理和人力资源软件等企业应用都用 LDAP 来验证用户身份，并访问和查找目录信息。<sup>[1](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/auth-ldap?source=recommendations)</sup>

| 关键事实 | 详情 |
|---|---|
| 首个规范 | RFC 1487，《X.500 轻量级目录访问协议》，1993 年 7 月<sup>[3](https://www.rfc-editor.org/info/rfc1487/)</sup> |
| 现行核心协议 | LDAPv3，由 RFC 4511（2006 年 6 月）定义，取代 RFC 2251、RFC 2830 和 RFC 3771<sup>[4](https://datatracker.ietf.org/doc/html/rfc4511)</sup> |
| 身份验证 | RFC 4513 定义了简单绑定（匿名、未验证、名称/密码）与 SASL 绑定方法，包括 EXTERNAL，以及 StartTLS 操作<sup>[5](https://datatracker.ietf.org/doc/rfc4513/)</sup> |
| 传输 | 协议操作直接承载于 TCP 或其他传输之上，绕过了 X.500 DAP 的大部分会话层与表示层开销<sup>[6](https://www.rfc-editor.org/info/rfc2251/)</sup> |
| 常用端口 | 端口 389 用于 LDAP 与 StartTLS；端口 636 用于基于 SSL 或 TLS 的 LDAP（LDAPS）<sup>[7](https://learn.microsoft.com/en-us/entra/id-governance/scenarios/provision-ldap)</sup> |
| 安全警示 | 除非采用 SSL/TLS 加密，LDAP 默认以明文传输凭据<sup>[8](https://www.mdpi.com/1999-5903/17/1/1)</sup> |
| 典型用途 | 企业应用的身份验证与属性查询；Microsoft Active Directory 将 LDAP 作为其访问协议之一<sup>[1](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/auth-ldap?source=recommendations)</sup><sup> • </sup><sup>[9](https://www.okta.com/identity-101/ldap-vs-active-directory/)</sup> |

## 起源与目的

LDAP 目录源自建立在 1988 年和 1993 年国际电信联盟（ITU）X.500 系列国际标准之上的项目与产品；这些标准制定时的假设是，X.400 电子消息传递将成为主流的商务电子邮件系统。X.400 并未取得那样的地位，但 X.500 存续了下来，LDAP 的许多协议特性以及模式（schema）和数据模型，都源自 X.500 规范，也源自 IETF 的 OSI-DS 工作组早期在实用互联网目录方面所做的工作。<sup>[2](https://ldap.com/wp-content/uploads/2018/05/internet-directory-services-using-the-lightweight-directory-access-protocol.pdf)</sup>

据 1993 年该协议的共同发明人蒂姆·豪斯（Tim Howes）说，LDAP 的诞生是为了给 X.500 目录提供低开销的访问方式。名称中的“轻量级”反映的是一种设计选择：运行在 TCP 之上，采用更简单的编码，而不是完整的 X.500 目录访问协议（DAP）协议栈。<sup>[6](https://www.rfc-editor.org/info/rfc2251/)</sup>

## 协议版本

**LDAPv2。** 版本 2 规范 RFC 1777 由 W. Yeong、T. Howes 与 S. Kille 于 1995 年 3 月在 IETF 的目录访问、搜索与索引（ASID）工作组下发表。<sup>[10](https://www.rfc-editor.org/info/rfc1777/)</sup> RFC 3494 后来建议将 LDAPv2 及其相关规范（RFC 1777、1778、1779、1781 和 2559）转为“历史”状态，理由是自其作为草案标准发表以来发现了若干不足。<sup>[11](https://www.rfc-editor.org/info/rfc3494/)</sup>

**LDAPv3。** 1997 年 12 月发表的 RFC 2251 将 LDAP 版本 3 定义为建议标准。其要点包括：支持全部 LDAPv2 协议元素；直接承载于 TCP 或其他传输之上；大多数数据元素（如可分辨名称）采用字符串编码；可转介至其他服务器（referral）；以及使用 SASL 机制进行身份验证。<sup>[6](https://www.rfc-editor.org/info/rfc2251/)</sup>

**2006 年修订版。** 现行技术规范定于 2006 年 6 月。由库尔特·蔡伦加（Kurt Zeilenga）主持的 LDAPbis 工作所编辑的协议文档 RFC 4511 取代了 RFC 2251、RFC 2830 和 RFC 3771，并与关于目录信息模型的 RFC 4512、关于身份验证方法的 RFC 4513 一道，构成 LDAP 技术规范路线图（RFC 4510）的一部分。<sup>[4](https://datatracker.ietf.org/doc/html/rfc4511)</sup><sup> • </sup><sup>[12](https://www.rfc-editor.org/info/rfc4510/)</sup><sup> • </sup><sup>[5](https://datatracker.ietf.org/doc/rfc4513/)</sup>

## 协议如何工作

该协议模型是客户端对服务器执行操作。客户端代表某个目录用户，发送描述所要执行操作的协议请求；服务器在目录中执行该操作，通常返回包含相应数据的响应。每个操作都作为原子动作处理，使目录保持一致状态；由于并不要求任何一方以同步方式运行，多个操作的请求与响应可以任意顺序交换。<sup>[4](https://datatracker.ietf.org/doc/html/rfc4511)</sup>

核心操作可以映射到 X.500（1993）目录抽象服务的一个子集，但与 X.500 DAP 操作的映射并非一一对应；作为 X.500 目录网关的服务器，可能需要发出多个 DAP 请求才能处理一个 LDAP 请求。<sup>[4](https://datatracker.ietf.org/doc/html/rfc4511)</sup> 早期实现支持的操作有绑定、搜索、比较、添加、删除、修改、修改 RDN 和放弃，读取与列举则通过搜索来模拟。<sup>[13](https://www.ietf.org/rfc/rfc1632.txt.pdf)</sup> 消息装在 LDAPMessage 信封中传输，信封携带的消息 ID 将每个响应与其请求对应起来，采用基本编码规则（BER）编码，并直接映射到 TCP 字节流上；会话通常在客户端发送 UnbindRequest（解绑请求）或服务器发送断连通知时结束。<sup>[14](https://www.ietf.org/ietf-ftp/rfc/rfc4511.txt.pdf)</sup>

## 身份验证与安全

绑定操作在客户端与服务器之间交换身份验证信息，以建立新的授权状态。RFC 4513 详述了简单绑定方法（涵盖匿名、未验证和名称/密码三种机制）与简单认证和安全层（SASL）绑定方法，包括 EXTERNAL 机制——在该机制中，由较低安全层交换的凭据来标识客户端。<sup>[5](https://datatracker.ietf.org/doc/rfc4513/)</sup>

**传输保护。** StartTLS 扩展操作在已有的 LDAP 会话中建立[传输层安全](https://www.edgepedia.org/zh/transport-layer-security)。若客户端打算同时执行 StartTLS 和绑定，应先执行 StartTLS，这样绑定交换便受到由此建立的数据安全服务的保护。为防止中间人攻击，客户端必须验证服务器证书中所呈现的服务器身份。<sup>[5](https://datatracker.ietf.org/doc/rfc4513/)</sup> 实践中，目录服务器在端口 389 上监听 LDAP 与 StartTLS，在端口 636 上监听 LDAPS。<sup>[7](https://learn.microsoft.com/en-us/entra/id-governance/scenarios/provision-ldap)</sup>

明文风险是实实在在的：LDAP 默认以明文传输凭据，除非采用 SSL/TLS 加密，否则会带来严重的安全风险。<sup>[8](https://www.mdpi.com/1999-5903/17/1/1)</sup> RFC 2829——这份 2000 年的身份验证方法文档后来被 RFC 4513 取代——直言不讳地指出，LDAP 的“简单”身份验证选项不适用于没有网络层或传输层机密性的互联网上的身份验证。<sup>[15](https://www.rfc-editor.org/info/rfc2829/)</sup>

## LDAP 与 Active Directory

LDAP 是一种协议；[Active Directory](https://www.edgepedia.org/zh/active-directory) 是微软的目录服务，是一个把 LDAP 作为其底层访问协议之一的产品。基于 LDAP 的应用可以在 Active Directory 环境中工作，但两者在性质上根本不同：Active Directory 面向管理基于微软的企业环境，而基于 LDAP 的目录服务器适合大规模、分布式的身份验证负载，例如无线通信平台中数以百万计的订户查询。<sup>[9](https://www.okta.com/identity-101/ldap-vs-active-directory/)</sup> 协议在各目录产品之间是标准的，但应用所遇到的目录语义仍可能因服务器背后的产品而异。<sup>[16](https://nhimg.org/faq/how-should-teams-decide-whether-ldap-or-active-directory-is-the-better-fit-for-a/)</sup>

**云集成。** Microsoft Entra ID 通过 Microsoft Entra 域服务支持依赖 LDAP 的应用；后者从 Microsoft Entra ID 进行单向同步，并向指定的 Azure 虚拟网络中的资源提供常见的 Active Directory 功能，包括 LDAP、域加入、组策略、[Kerberos](https://www.edgepedia.org/zh/kerberos-protocol) 和 NTLM 身份验证。这使采取“云优先”战略的组织能够把依赖 LDAP 的旧有应用从本地 LDAP 资源上迁移出来。<sup>[1](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/auth-ldap?source=recommendations)</sup> 在规划将应用身份验证迁移到 SAML、[OpenID Connect](https://www.edgepedia.org/zh/openid-connect) 等现代协议时，微软还把 LDAP 归入旧有协议之列（与 Kerberos、RADIUS 和 NTLM 并列），并建议应用通过联合或单点登录协议向 Microsoft Entra ID 进行身份验证，仅把目录服务器用于属性查询。<sup>[17](https://learn.microsoft.com/en-us/entra/architecture/road-to-the-cloud-migrate)</sup><sup> • </sup><sup>[7](https://learn.microsoft.com/en-us/entra/id-governance/scenarios/provision-ldap)</sup>

## 目录适合做什么，不适合做什么

目录通常以读取为主而非以写入为主，并且支持相对简单的事务模型：一个事务只涉及对单个目录条目的单个操作。需要写入大量数据、或需要跨多个数据项事务的应用，应当改用数据库。目录也不适合充当文件系统：它为存储和检索相对较小的信息片段而优化，并且无法从某个字节偏移开始检索属性值的一部分。<sup>[18](https://www.pearsonhighered.com/assets/samplechapter/1/5/7/8/1578700701.pdf)</sup> 同样，LDAP 目录缺少触发器和事务等某些基本数据库功能，这一局限促成了 LTAP（轻量级触发器访问进程）项目之类的研究网关——该项目为 LDAP 目录添加主动功能，以完成电信集成任务。<sup>[19](https://www.researchwithrutgers.org/en/publications/making-ldap-active-with-the-ltap-gateway-case-study-in-providing-/)</sup>

服务器实现通过复制来解决规模与可用性问题。在 OpenLDAP 中，LDAP 同步复制引擎（syncrepl）是一个消费者端引擎，让副本服务器维护目录信息树某一分片的影子副本：先加载初始内容，随后按周期性轮询或内容变更的及时更新来跟进；部署方案还包括 delta-syncrepl 和 N 路多提供者复制。<sup>[20](https://www.openldap.org/doc/admin25/replication.html)</sup>

## References

1. [LDAP authentication with Microsoft Entra ID, Microsoft Learn](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/auth-ldap?source=recommendations)
2. [Internet Directory Services: Using the Lightweight Directory Access Protocol (PDF), ldap.com](https://ldap.com/wp-content/uploads/2018/05/internet-directory-services-using-the-lightweight-directory-access-protocol.pdf)
3. [RFC 1487: X.500 Lightweight Directory Access Protocol, RFC Editor](https://www.rfc-editor.org/info/rfc1487/)
4. [RFC 4511: LDAP: The Protocol, IETF Datatracker](https://datatracker.ietf.org/doc/html/rfc4511)
5. [RFC 4513: LDAP: Authentication Methods and Security Mechanisms, IETF Datatracker](https://datatracker.ietf.org/doc/rfc4513/)
6. [RFC 2251: LDAP (v3), RFC Editor](https://www.rfc-editor.org/info/rfc2251/)
7. [Govern provisioning to on-premises LDAP based apps, Microsoft Learn](https://learn.microsoft.com/en-us/entra/id-governance/scenarios/provision-ldap)
8. [A Comparative Survey of Centralised and Decentralised Identity Management Systems, Future Internet (MDPI)](https://www.mdpi.com/1999-5903/17/1/1)
9. [LDAP vs. Active Directory: What's the Difference?, Okta](https://www.okta.com/identity-101/ldap-vs-active-directory/)
10. [RFC 1777: Lightweight Directory Access Protocol, RFC Editor](https://www.rfc-editor.org/info/rfc1777/)
11. [RFC 3494: LDAPv2 to Historic Status, RFC Editor](https://www.rfc-editor.org/info/rfc3494/)
12. [RFC 4510: LDAP: Technical Specification Road Map, RFC Editor](https://www.rfc-editor.org/info/rfc4510/)
13. [RFC 1632: A Catalog of Available X.500 Implementations, IETF](https://www.ietf.org/rfc/rfc1632.txt.pdf)
14. [RFC 4511 (PDF), IETF](https://www.ietf.org/ietf-ftp/rfc/rfc4511.txt.pdf)
15. [RFC 2829: Authentication Methods for LDAP, RFC Editor](https://www.rfc-editor.org/info/rfc2829/)
16. [How should teams decide whether LDAP or Active Directory is the better fit?, nhimg.org](https://nhimg.org/faq/how-should-teams-decide-whether-ldap-or-active-directory-is-the-better-fit-for-a/)
17. [Road to the cloud: Move identity and access management from AD DS to Microsoft Entra, Microsoft Learn](https://learn.microsoft.com/en-us/entra/architecture/road-to-the-cloud-migrate)
18. [Understanding and Deploying LDAP Directory Services, Chapter 1 sample (Pearson)](https://www.pearsonhighered.com/assets/samplechapter/1/5/7/8/1578700701.pdf)
19. [Making LDAP active with the LTAP gateway, University of Rutgers research](https://www.researchwithrutgers.org/en/publications/making-ldap-active-with-the-ltap-gateway-case-study-in-providing-/)
20. [OpenLDAP Software 2.5 Administrator's Guide: Replication](https://www.openldap.org/doc/admin25/replication.html)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Networking fundamentals and architecture › Internet protocol suite

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/lightweight-directory-access-protocol

English original: https://www.edgepedia.org/lightweight-directory-access-protocol
