What Are Distinguished Names (DNs) in LDAP?

Share This Article

Updated on April 14, 2025

When working with LDAP (Lightweight Directory Access Protocol), understanding distinguished names (DNs) is crucial. They act as unique identifiers for entries in an LDAP Directory Information Tree (DIT), forming the foundation of directory organization. This article breaks down the core concepts, components, and practical uses of DNs.

Definition and Core Concepts

A distinguished name (DN) is a unique identifier that pinpoints a specific object in an LDAP directory. It details the object’s hierarchical position within the directory tree, ensuring every entry is distinctly identifiable.

Core Concepts of DNs

  • Directory Entry: A DN refers to an object stored in the LDAP directory, such as a user, group, or organizational unit.
    • For example: A user named John Doe might have a DN of cn=John Doe,ou=Sales,dc=example,dc=com, which specifies “John Doe” in the “Sales” organizational unit under the “example.com” domain.
  • Hierarchical Structure: LDAP organizes data in a tree-like hierarchy, and the DN reflects the entry’s precise position within this structure. The topmost entry is the “root,” and all subsequent entries branch off.
  • Components of a DN: A DN is built as a sequence of relative distinguished names (RDNs), separated by commas. For example:

cn=John Doe,ou=Sales,dc=example,dc=com

  • cn=John Doe: Common Name (the RDN for this entry)
  • ou=Sales: Organizational Unit
  • dc=example,dc=com: Domain Components forming the root.
  • Relative Distinguished Name (RDN): Each DN contains one or more RDNs. An RDN serves as the unique part of the entry name. For example, in cn=John Doe, “John Doe” is unique within its parent object (e.g., the Sales unit).
  • Attribute-Value Pairs: RDNs typically consist of attribute-value pairs. Common attributes include:
    • cn: Common Name (e.g., cn=John Doe)
    • ou: Organizational Unit (e.g., ou=HR)
    • dc: Domain Component (e.g., dc=example)
    • uid: User Identifier (e.g., uid=jdoe)
  • Root DN: The root DN is the top-level entry in the LDAP DIT and generally represents an organization’s domain. For instance, dc=example,dc=com indicates the example.com domain.

How DNs Work in LDAP

LDAP relies on DNs to effectively organize and access entries within a directory. Here’s how they function:

Building a DN 

A DN is constructed by concatenating the RDN of an entry with the DNs of its parent entries, starting from the bottom and moving to the root. 

For instance:

cn=John Doe
ou=Sales
dc=example
dc=com

These components come together as cn=John Doe,ou=Sales,dc=example,dc=com.

Locating Entries 

LDAP clients use DNs to locate specific entries. If an application needs John Doe’s contact details, it can retrieve the entry directly using its DN.

Search Base 

A DN can be used as a “search base” to define the starting point for LDAP queries. For example, if you search starting from ou=Sales,dc=example,dc=com, the query will target entries within the “Sales” organizational unit.

Modification Operations 

LDAP modifications, such as renaming or updating attributes, require a DN to specify the target entry to be edited.

Binding (Authentication) 

DNs, combined with passwords, are often used for authentication. For example, cn=John Doe,ou=Sales,dc=example,dc=com may be provided as the user DN when logging in to an LDAP-based application.

Key Features and Components of DNs

Distinguished Names have specific features that drive LDAP’s efficiency and reliability:

  • Uniqueness: Every entry in an LDAP DIT is uniquely identified by its DN, eliminating any ambiguity.
  • Hierarchy Representation: A DN clearly reflects the directory’s tree-like organization, helping administrators visualize relationships between entries.
  • Readability: While designed for machines, DNs also follow a logical and readable structure, making them decipherable for humans.
  • Path-Like Structure: The DN’s structuring mirrors a file system’s directory structure, facilitating logical navigation.
  • Case Insensitivity (Typically): Most LDAP implementations handle DNs case-insensitively when processing values. For example, cn=John Doe and cn=john doe are considered equivalent.

Use Cases and Applications of DNs in LDAP

Distinguished Names are critical in various LDAP-based operations, including:

  • User Authentication: DNs are used to identify users when logging into LDAP-enabled services. For instance: User DN: uid=jdoe,ou=Engineering,dc=example,dc=com
  • Group Membership Management: DNs enable hierarchical management of directory entries. For example, a group DN like cn=Admins,ou=Groups,dc=example,dc=com contains a list of admin users.
  • Resource Location: LDAP directories can store server, printer, and other network resource information, locating them through DNs.
  • Organizational Structure Representation: Hierarchical structures like departments, teams, and geographical locations can be modeled using DNs.  Example DN for HR in New York: ou=HR,ou=NYC,dc=example,dc=com
  • Access Control Lists (ACLs): Permissions within LDAP are managed using DNs. Access rights can be defined for specific entries based on DNs.  Example rule: Grant access to cn=Mary,ou=Finance,dc=example,dc=com

Advantages and Trade-Offs of Using DNs

While DNs are vital to LDAP’s design, they come with both benefits and challenges.

Benefits

  • Guaranteed Uniqueness: Every entry has a distinct DN, avoiding conflicts.
  • Clear Hierarchical Context: DNs show exactly where an entry fits within the directory.
  • Efficient Direct Access: DNs enable direct querying of entries for faster operations.

Trade-Offs

  • Verbosity: DNs can become lengthy and complex in deep hierarchies.
  • Sensitivity to Organizational Changes: Moving or renaming entries may require significant updates to dependent configurations.
  • Potential for Naming Conflicts: Without proper planning, duplicate RDNs in the same parent can cause issues.

Key Terms Appendix

  • LDAP: Open, vendor-neutral protocol for accessing directory services. 
  • DIT (Directory Information Tree): Tree structure used to organize entries in LDAP. 
  • Directory Entry: A record in the LDAP directory that stores information about an object. 
  • RDN (Relative Distinguished Name): The unique part of a DN within its parent entry. 
  • Attribute: A characteristic or property of an LDAP entry (e.g., cn, ou, dc). 
  • Schema: Set of rules that defines LDAP’s structure and attribute relations. 
  • Bind: The process of authenticating to the LDAP directory using a DN and credentials.

Continue Learning with our Newsletter