Lightweight Directory Access Protocol
In computer networking, the Lightweight Directory Access Protocol, or LDAP ("ell-dap"), is a networking protocol for querying and modifying directory services running over TCP/IP. An LDAP directory usually follows the X.500 model: it is a tree of entries, each of which consists of a set of named attributes with values. While some services use a more complicated "forest" model, the vast majority use a simple starting point for their database organization.
An LDAP directory often reflects various political, geographic, and/or organizational boundaries, depending on the model chosen. LDAP deployments today tend to use Domain Name System (DNS) names for structuring the most simple levels of the hierarchy. Further into the directory might appear entries representing people, organizational units, printers, documents, groups of people or anything else which represents a given tree entry, or multiple entries.
Its current version is LDAPv3. LDAPv3 is specified in a series of IETF Standard Track RFCs as detailed in RFC 4510.
Origin and influences
LDAP was originally intended to be a lightweight alternative protocol for accessing X.500 directory services. X.500 directory services were traditionally accessed via the X.500 Directory Access Protocol, or DAP, which required the cumbersome Open Systems Interconnection (OSI) protocol stack. With LDAP, a client could access these directory services through an LDAP-to-DAP gateway. The gateway would translate LDAP requests to DAP requests and DAP responses to LDAP. This model of directory access was borrowed from DIXIE and the Directory Assistance Service.
Standalone LDAP directory servers soon followed, as did directory servers supporting both DAP and LDAP. The former has become popular in enterprises as they removed any need to deploy an OSI network. Today, X.500 directory protocols including DAP can be also used directly over TCP/IP.
The protocol was originally created by Tim Howes of the University of Michigan, Steve Kille of ISODE and Wengyik Yeong of Performance Systems International, circa 1993. Further development has been done via the Internet Engineering Task Force (IETF).
Note that in the early engineering stages of LDAP, it was known as Lightweight Directory Browsing Protocol or LDBP. It was renamed as the scope of the protocol was expanded to not only include directory browsing functions (e.g., search) but also directory update functions (e.g., modify).
LDAP has influenced subsequent Internet protocols, including later versions of X.500, XML Enabled Directory (XED), Directory Services Markup Language (DSML), Service Provisioning Markup Language (SPML), and the Service Location Protocol (SLP).
Protocol overview
A client starts an LDAP session by connecting to an LDAP server, by default on TCP port 389. The client then sends operation requests to the server, and the server sends responses in return. With some exceptions the client need not wait for a response before sending the next request, and the server may then send the responses in any order.
The basic operations are, in order:
- Bind - authenticate, and specify LDAP protocol version,
- Start TLS - protect the connection with Transport Layer Security (TLS), to have a more secure connection,
- Search - search for and/or retrieve directory entries,
- Compare - test if a named entry contains a given attribute value,
- Add a new entry,
- Delete an entry,
- Modify an entry,
- Modify DN - move or rename an entry,
- Abandon - abort a previous request,
- Extended Operation - generic operation used to define other operations,
- Unbind - close the connection, not the inverse of Bind.
In addition the server may send "Unsolicited Notifications" that are not responses to any request, e.g. before it times out a connection.
A common alternate method of securing LDAP communication is using an SSL tunnel. This is denoted in LDAP URLs by using the URL scheme "ldaps". The standard port for LDAP over SSL is 636.
LDAP is defined in terms of ASN.1, and protocol messages are encoded in the binary format BER. It uses textual representations for a number of ASN.1 fields/types, however.
Directory structure
The protocol accesses LDAP directories, which follow the X.500 model:
A directory is a tree of directory entries.
An entry consists of a set of attributes.
An attribute has a name (an attribute type or attribute description) and one or more values.
The attributes are defined in a schema (see below).
Each entry has a unique identifier: its Distinguished Name (DN). This consists of its Relative Distinguished Name (RDN) constructed from some attribute(s) in the entry, followed by the parent entry's DN. Think of the DN as a full filename and the RDN as a relative filename in a folder.
Be aware that a DN may change over the lifetime of the entry, for instance, when entries are moved within a tree. To reliably and unambiguously identify entries, a UUID may be provided in the set of the entry's operational attributes.
An entry can look like this when represented in LDIF format (LDAP itself is a binary protocol):
dn: cn=John Doe,dc=example,dc=com cn: John Doe givenName: John sn: Doe telephoneNumber: +1 555 6789 telephoneNumber: +1 555 1234 mail: john@example.com manager: cn=Barbara Doe,dc=example,dc=com objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person objectClass: top
dn is the name of the entry; it's not an attribute nor part of the entry. "cn=John Doe" is the entry's RDN, and "dc=example,dc=com" is the DN of the parent entry. The other lines show the attributes in the entry. Attribute names are typically mnemonic strings, like "cn" for common name, "dc" for domain component, and "mail" for e-mail address.
A server holds a subtree starting from a specific entry, e.g. "dc=example,dc=com" and its children. Servers may also hold references to other servers, so an attempt to access "ou=Some department,dc=example,dc=com" could return a referral or continuation reference to a server which holds that part of the directory tree. The client can then contact the other server. Some servers also support chaining, which means the server contacts the other server and returns the results to the client.
LDAP rarely defines any ordering: The server may return the values in an attribute, the attributes in an entry, and the entries found by a search operation in any order.
Operations
The client gives each request a positive Message ID, and the server response has the same Message ID. The response includes a numeric result code indicating success, some error condition or some other special cases. Before the response, the server may send other messages with other result data - for example each entry found by the Search operation is returned in such a message.
Stub for discussion of referral responses to various operations, especially modify, for example where all modifies must be directed from replicas to a master directory.
Bind (authenticate)
The Bind operation authenticates the client to the server. Simple Bind sends the user's DN and password - in cleartext, so the connection should be protected using Transport Layer Security (TLS). The server typically checks the password against the userPassword attribute in the named entry. Anonymous Bind (with empty DN and password) resets the connection to anonymous state. SASL (Simple Authentication and Security Layer) Bind provides authentication services through a wide-range of mechanisms, e.g. Kerberos or the client certificate sent with TLS.
Bind also sets the LDAP protocol version. Normally clients should use LDAPv3, which is the default in the protocol but not always in LDAP libraries.
StartTLS
The StartTLS operation establishes Transport Layer Security (the descendant of SSL) on the connection. That can provide data confidentiality protection (hide the data) and/or data integrity protection (protect from tampering). During TLS negotiation the server sends its X.509 certificate to prove its identity. The client may also send a certificate to prove its identity. After doing so, the client may then use SASL/EXTERNAL to have this identity used in determining the identity used in making LDAP authorization decisions.
Servers also often support the non-standard "LDAPS" ("Secure LDAP", commonly known as "LDAP over SSL") protocol on a separate port, by default 636. The LDAPS differs from LDAP in two ways: 1) upon connect, the client and server establish TLS before any LDAP messages are transferred (without a Start TLS operation) and 2) the LDAPS connection must be closed upon TLS closure.
Search and Compare
The Search operation is used to both search for and read entries. Its parameters are:
- baseObject - the DN (Distinguished Name) of the entry at which to start the search,
- scope - baseObject (search just the named entry, typically used to read one entry), singleLevel (entries immediately below the base DN), or wholeSubtree (the entire subtree starting at the base DN).
- filter - how to examine each entry in the scope. E.g. (&(objectClass=person)(|(givenName=John)(mail=john*))) - search for persons who either have given name John or an e-mail address starting with john.
- derefAliases - whether and how to follow alias entries (entries which refer to other entries),
- attributes - which attributes to return in result entries.
- sizeLimit, timeLimit - max number of entries, and max search time.
- typesOnly - return attribute types only, not attribute values.
The server returns the matching entries and maybe continuation references (in any order), followed by the final result with the result code.
The Compare operation takes a DN, an attribute name and an attribute value, and checks if the named entry contains that attribute with that value.
Update operations
Add, Delete, and Modify DN - all require the DN of the entry that is to be changed.
Modify takes a list of attributes to modify and the modifications to each: Delete the attribute or some values, add new values, or replace the current values with the new ones.
Add operations also can have additional attributes and values for those attributes.
Modify DN (move/rename entry) takes the new RDN (Relative Distinguished Name), optionally the new parent's DN, and a flag which says whether to delete the value(s) in the entry which match the old RDN. The server may support renaming of entire directory subtrees.
An update operation is atomic: Other operations will see either the new entry or the old one. On the other hand, LDAP does not define transactions of multiple operations: If you read an entry and then modify it, another client may have updated the entry in the mean time. Servers may implement extensions which support this, however.
Extended operations
The Extended Operation is a generic LDAP operation which can be used to define new operations. Examples include the Cancel, Password Modify and Start TLS operations.
Abandon
The Abandon operation requests that the server aborts an operation named by a message ID. The server need not honor the request. Unfortunately, neither Abandon nor a successfully abandoned operation send a response. A similar Cancel extended operation has therefore been defined which does send responses, but not all implementations support this.
Unbind
The Unbind operation abandons any outstanding operations and closes the connection. It has no response. The name is of historical origin: It is not the opposite of the Bind operation.
Clients can abort a session by simply closing the connection, but they should use Unbind. Otherwise the server cannot tell the difference between a failed network connection (or a truncation attack) and a discourteous client.
LDAP URLs
An LDAP URL format exists which clients support in varying degree, and which servers return in referrals and continuation references:
"ldap://host:port/DN?attributes?scope?filter?extensions"
where most components after "ldap://" can be omitted.
scope can be "base" (the default), "one" or "sub".
attributes is a comma-separated list of attributes to retrieve.
extensions are extensions to the LDAP URL format.
As in other URLs, special characters must be escaped with %hex format.
There is a similar non-standard "ldaps:" URL scheme for LDAP over SSL.
For example, "ldap://ldap.example.com/cn=John%20Doe,dc=example,dc=com" refers to all user attributes in John Doe's entry in ldap.example.com. "ldap:///dc=example,dc=com??sub?(givenName=John)" searches for him in the default server.
Schema
The contents of the entries in a subtree is governed by a schema.
The schema defines the attribute types that directory entries can contain. An attribute definition includes a syntax, and most non-binary values in LDAPv3 use UTF-8 string syntax. For example, a "mail" attribute might contain the value "user@example.com". A "jpegPhoto" attribute would contain photograph(s) in binary JPEG/JFIF format. A "member" attribute contains the DNs of other directory entries. Attribute definitions also specify whether the attribute is single-valued or multi-valued, how to search/compare the attribute (e.g. case-sensitive vs. case-insensitive and whether substring matching is supported), etc.
The schema defines object classes. Each entry must have an objectClass attribute, containing named classes defined in the schema. Typically, the objectClass attribute is multivalued, and contains the class "top" as well as some number of other classes. The schema definition for each class an entry belongs to defines what kind of object the entry may represent - e.g. a person, organization or domain. Practically this means that membership in a particular class gives the entry the option of containing one set of attributes (optional attributes), and the obligation of containing another set (mandatory or required attributes). For example, an entry representing a person might belong to the classes "top" and "person". Membership in the "person" class would require the entry to contain the "sn" and "cn" attributes, and allow the entry also to contain "userPassword", "telephoneNumber", and other attributes. Since entries may belong to multiple classes, each entry has a complex of optional and mandatory attribute sets formed from the union of the object classes it represents.
The schema also includes various other information controlling directory entries.
Most schema elements have a name and a globally unique Object identifier (OID).
Many directory servers publish the directory schema itself as a collection of LDAP entries rooted at the base DN cn=schema.
Server administrators can define their own schemas in addition to the standard ones. A schema for representing individual people within organizations is termed a white pages schema.
Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź À à È è Ì ì Ò ò Ù ù  â Ĉ ĉ Ê ê Ĝ ĝ Ĥ ĥ Î î Ĵ ĵ Ô ô Ŝ ŝ Û û Ŵ ŵ Ŷ ŷ Ä ä Ë ë Ï ï Ö ö Ü ü Ÿ ÿ ß Ã ã Ẽ ẽ Ĩ ĩ Ñ ñ Õ õ Ũ ũ Ỹ ỹ Ç ç Ģ ģ Ķ ķ Ļ ļ Ņ ņ Ŗ ŗ Ş ş Ţ ţ Đ đ Ů ů Ǎ ǎ Č č Ď ď Ě ě Ǐ ǐ Ľ ľ Ň ň Ǒ ǒ Ř ř Š š Ť ť Ǔ ǔ Ž ž Ā ā Ē ē Ī ī Ō ō Ū ū Ȳ ȳ Ǣ ǣ ǖ ǘ ǚ ǜ Ă ă Ĕ ĕ Ğ ğ Ĭ ĭ Ŏ ŏ Ŭ ŭ Ċ ċ Ė ė Ġ ġ İ ı Ż ż Ą ą Ę ę Į į Ǫ ǫ Ų ų Ḍ ḍ Ḥ ḥ Ḷ ḷ Ḹ ḹ Ṃ ṃ Ṇ ṇ Ṛ ṛ Ṝ ṝ Ṣ ṣ Ṭ ṭ Ł ł Ő ő Ű ű Ŀ ŀ Ħ ħ Ð ð Þ þ Œ œ Æ æ Ø ø Å å Ə ə • Template:Latinx
Variations
A lot of the server operation is left to the implementor or administrator to decide. Accordingly, servers may be set up to support a wide variety of scenarios.
For example, data storage in the server is not specified - the server may use flat files, databases, or just be a gateway to some other server. Access control is not standardized, though there has been work on it and there are commonly used models. Users' passwords may be stored in their entries or elsewhere. The server may refuse to perform operations when it wishes, and impose various limits.
Most parts of LDAP are extensible. Examples: One can define new operations. Controls may modify requests and responses, e.g. to request sorted search results. New search scopes and Bind methods can be defined. Attributes can have options that may modify their semantics.
Other data models
As LDAP has gained momentum, vendors have provided it as an access protocol to other services. The implementation then recasts the data to mimic the LDAP/X.500 model, but how closely this model is followed varies. For example, there is software to access SQL databases through LDAP, even though LDAP does not readily lend itself to this. X.500 servers may support LDAP as well.
Similarly, data which were previously held in other types of data stores are sometimes moved to LDAP directories. For example, Unix user and group information can be stored in LDAP and accessed via PAM and NSS modules. LDAP is often used by other services for authentication.
Terminology
Beware: The LDAP terminology one can encounter is quite a mess. Some of this is due to misunderstandings, other examples are due to its historical origins, others arise when used with non-X.500 services that use different terminology.
For example, "LDAP" is sometimes used to refer to the protocol, other times to the protocol and the data. An "LDAP directory" may be the data or also the access point. An "attribute" may be the attribute type, or the contents of an attribute in a directory, or an attribute description (an attribute type with options). An "anonymous" and an "unauthenticated" Bind are different Bind methods that both produce anonymous authentication state, so both terms are being used for both variants. The "uid" attribute should hold user names rather than numeric user IDs.
Supporting vendors
LDAP has gained wide support from vendors such as:
- Apache (through Apache Directory Server)
- Apple (through Open Directory/OpenLDAP)
- AT&T
- Avaya (through Directory Enabled Management)
- Banyan
- Critical Path
- eB2Bcom (through View500)
- Fedora Directory Server
- Hewlett-Packard
- Identyx
- IBM/Lotus
- ISODE (through M-Vault server)
- MaXware (through MaXware Virtual Directory)
- Microsoft (through Active Directory)
- Netscape (now in Sun Microsystems and Red Hat products)
- Novell (through eDirectory)
- OctetString (through VDE server)
- Oracle (through Oracle Internet Directory)
- Radiant Logic (through RadiantOne Virtual Directory Server)
- Red Hat Directory Server
- Siemens AG (through DirX server)
- SGI and
- Sun (through the iPlanet and Sun ONE directory servers)
- Symlabs (through Directory Extender)
as well as in open source/free software implementations such as OpenLDAP and Fedora Directory Server. Also the Apache HTTP Server used as a proxy (by the module mod_proxy) supports LDAP.
LDAP implementations
- Apache Directory Server
- Critical Path Directory Server and Meta Directory Server
- Fedora Directory Server
- Red Hat Directory Server
- OpenLDAP
- Novell eDirectory
- Sun Directory Server
- IBM SecureWay Directory
- IBM Tivoli Directory Server (formerly IBM Directory Server)
- Windows Server 2003 Active Directory
- Siemens DirX
- View500
- Oracle Internet Directory
- tinyldap a small LDAP implementation
- LDAP clients and libraries:
- LDAPxl, A directory services add-in for Microsoft Office that allows you to query LDAP servers and import data directly into your Excel worksheet, Word document, and Access database.
- phpLDAPadmin, a web-based LDAP browser/server manager
- EDS Admin tool
- Softerra Freeware Browser and paid for Administrator products
- JXplorer java OSS LDAP Client
- GQ (Homepage)
- Luma (Homepage)
- Net::LDAP Perl API, written in Perl
- PerLDAP, an interface to the C SDK API, and a set of Object Oriented Perl classes
- Python-LDAP, LDAP API for the Python language
- ActiveLDAP, Object oriented LDAP API for Ruby
- Ruby Net::LDAP, Pure Ruby LDAP API
- MaXware - Directory Explorer (free Windows LDAP Browser client)
- Mozilla Directory (LDAP) SDK Project - clients and C, Java and Perl libraries
- Gosa Gosa: A PHP Based Admin tool
- Jamm Jamm, (Java Mail Manager) is a web application to manage virtual email account information stored in an LDAP directory.
- LDAP Admin, an open source LDAP client for Windows
References
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
- [1]LDAP: Framework, Practices, and Trends
- The X.500 series - ITU-T Rec. X.500 to X.521
- ITU-T Rec. X.680, "Abstract Syntax Notation One (ASN.1) - Specification of Basic Notation", 1994
- Basic encoding rules (BER) - ITU-T Rec. X.690, "Specification of ASN.1 encoding rules: Basic, Canonical, and Distinguished Encoding Rules", 1994
- RFC 4346 - The TLS Protocol Version 1.1
- RFC 4422 - Simple Authentication and Security Layer (SASL)
- SASL mechanisms registered at IANA
See also
- LDAP Data Interchange Format
- LDAP Application Program Interface
- Directory service
- X.500
- Transport Layer Security (TLS)
- Simple Authentication and Security Layer (SASL)
External links
- PALDAP, A Lazy Directory Administrator's Pal A fairly new LDAP Wiki
- Public LDAP Servers Look up people at many different universities, institutions, etc.
- Linux LDAP HOWTO
- LDAP Articles, Links, Whitepapers
- LDAP Software, Tools & Utilities
- Nice Neat Introduction To LDAP with examples
- OpenLDAP install for Windows with support of the LDAPS protocol
- Using OpenLDAP - Installing OpenLDAP under Debian GNU/Linux
- LDAP Authentication for Linux - Integrating LDAP into PAM
- LDAP Libraries for C#.
- LDAP for Rocket Scientists - Comprehensive LDAP Guide/Tutorial
- OpenLDAP Chaining - A guide to chaining implementation with OpenLDAP
- The importance of LDAP A commentary by Tom Jackiewicz about LDAP
- HOWTO on LDAP + SASL + KERBEROS Master/Slave Central Authentication A Complex Howto By Danang Wijanarko
- LDAP to SQL - Perl code extracting from a hierarchical structure and producing a relational one
- A Wiki for using LDAP in Debian
- A loose collection of Linux LDAP tutorials
LDAP fora
- LDAP mailinglist at umich.edu
- "#ldap" IRC channel in the freenode IRC network
- LDAP (v3) Revision (ldapbis) Working Group
- LDAPext (LDAP Extensions) mailing list - originally created for an IETF working group. The list is archived at Gmane.
RFCs
LDAP is currently specified in a series of Request for Comments documents:
- RFC 4510 - Lighweight Directory Access Protocol (LDAP) Technical Specification Roadmap (replaced the previous LDAP Technical specification, RFC 3377, in its entirety)
- RFC 4511 - Lightweight Directory Access Protocol (LDAP): The Protocol
- RFC 4512 - Lightweight Directory Access Protocol (LDAP): Directory Information Models
- RFC 4513 - Lightweight Directory Access Protocol (LDAP): Authentication Methods and Security Mechanisms
- RFC 4514 - Lightweight Directory Access Protocol (LDAP): String Representation of Distinguished Names
- RFC 4515 - Lightweight Directory Access Protocol (LDAP): String Representation of Search Filters
- RFC 4516 - Lightweight Directory Access Protocol (LDAP): Uniform Resource Locator
- RFC 4517 - Lightweight Directory Access Protocol (LDAP): Syntaxes and Matching Rules
- RFC 4518 - Lightweight Directory Access Protocol (LDAP): Internationalized String Preparation
- RFC 4519 - Lightweight Directory Access Protocol (LDAP): Schema for User Applications
The following RFCs detail LDAP-specific Best Current Practices:
- RFC 4520 (also BCP 64) - Internet Assigned Numbers Authority (IANA) Considerations for the Lightweight Directory Access Protocol (LDAP) (replaced RFC 3383)
- RFC 4521 (also BCP 118) - Considerations for Lightweight Directory Access Protocol (LDAP) Extensions
The following is a partial list of RFCs specifying LDAPv3 extensions:
- RFC 2247 - Use of DNS domains in distinguished names
- RFC 2307 - Using LDAP as a Network Information Service
- RFC 2589 - LDAPv3: Dynamic Directory Services Extensions
- RFC 2649 - LDAPv3 Operational Signatures
- RFC 2696 - LDAP Simple Paged Result Control
- RFC 2798 - inetOrgPerson LDAP Object Class
- RFC 2849 - The LDAP Data Interchange Format (LDIF)
- RFC 2891 - Server Side Sorting of Search Results
- RFC 3045 - Storing Vendor Information in the LDAP root DSE
- RFC 3062 - LDAP Password Modify Extended Operation
- RFC 3296 - Named Subordinate References in LDAP Directories
- RFC 3671 - Collective Attributes in LDAP
- RFC 3672 - Subentries in LDAP
- RFC 3673 - LDAPv3: All Operational Attributes
- RFC 3687 - LDAP Component Matching Rules
- RFC 3698 - LDAP: Additional Matching Rules
- RFC 3829 - LDAP Authorization Identity Controls
- RFC 3866 - Language Tags and Ranges in LDAP
- RFC 3909 - LDAP Cancel Operation
- RFC 3928 - LDAP Client Update Protocol
- RFC 4370 - LDAP Proxied Authorization Control
- RFC 4373 - LBURP
- RFC 4403 - LDAP Schema for UDDI
- RFC 4522 - LDAP: Binary Encoding Option
- RFC 4523 - LDAP: X.509 Certificate Schema
- RFC 4524 - LDAP: COSINE Schema (replaces RFC 1274)
- RFC 4525 - LDAP: Modify-Increment Extension
- RFC 4526 - LDAP: Absolute True and False Filters
- RFC 4527 - LDAP: Read Entry Controls
- RFC 4528 - LDAP: Assertion Control
- RFC 4529 - LDAP: Requesting Attributes by Object Class
- RFC 4530 - LDAP: entryUUID
- RFC 4531 - LDAP Turn Operation
- RFC 4532 - LDAP Who am I? Operation
- RFC 4533 - LDAP Content Sync Operation
LDAPv2 was specified in the following RFCs:
- RFC 1777 - Lightweight Directory Access Protocol (replaced RFC 1487)
- RFC 1778 - The String Representation of Standard Attribute Syntaxes (replaced RFC 1488)
- RFC 1779 - A String Representation of Distinguished Names (replaced RFC 1485)
LDAPv2 was moved to historic status by the following RFC:
- RFC 3494 -Lightweight Directory Access Protocol version 2 (LDAPv2) to Historic Status