Skip to main content
Category: Directory Services

Distinguished Name

Also known as:
Simply put

A Distinguished Name (DN) is a unique name that identifies a specific entry in a directory system, much like a full address that pinpoints exactly one entity among many. It is built from a series of naming components that, taken together, distinguish that entry from all others. DNs are commonly used in directory systems and also appear in digital certificates to identify their subject.

Formal definition

A Distinguished Name (DN) is an identifier that uniquely represents an object within a directory information tree, originating in the X.500 directory model and widely used in LDAP directories. A DN is composed of an ordered sequence of Relative Distinguished Names (RDNs), each RDN being one or more attribute-value pairs (for example, cn=Jane Doe), with RDNs typically connected by commas to express the entry's position in the directory hierarchy. Beyond directory entries, DNs also appear in certificate systems, where the DN is a set of values supplied during enrollment and creation of a Certificate Signing Request (CSR) to identify the certificate subject. Exact syntax, attribute types, and ordering conventions depend on the standard profile and implementation.

Why it matters

The Distinguished Name is the anchor by which directory-based identity systems locate and reference a specific entry. Because a DN uniquely represents one object within the directory information tree, it functions as the canonical reference used in bind operations, search base definitions, group membership references, and access control entries. In most LDAP and X.500-derived deployments, an incorrect or ambiguous DN means the wrong entry is resolved, or none at all, so precision in DN construction directly affects whether identification and subsequent authentication succeed.

DNs also cross the boundary between directory services and certificate systems. When a Certificate Signing Request (CSR) is created, the DN is the set of values that identifies the certificate subject. This makes the DN a shared identity construct: the same conceptual naming approach that locates a directory entry also names the subject a certificate asserts. Misalignment between the DN expected by a relying system and the DN presented, whether in a directory bind or in a certificate subject field, can cause identification and validation to fail in ways that are easy to overlook.

Because exact syntax, attribute types, and ordering conventions depend on the standard profile and implementation, teams that treat DNs as free-form strings often encounter interoperability problems. Two DNs that appear equivalent to a human reader may not match under a given implementation's comparison rules, and RDN ordering is significant to the hierarchical meaning of the name. Understanding the DN as a structured, ordered identifier rather than an arbitrary label is essential for reliable directory operations and certificate handling.

Who it's relevant to

IAM Engineers and Directory Administrators
Engineers configuring LDAP directories rely on DNs to define search bases, perform bind operations, and reference entries in group memberships and access control settings. Because a DN uniquely identifies an entry through an ordered sequence of RDNs, accurate DN construction is fundamental to correct directory resolution, and RDN ordering must be handled as significant rather than arbitrary.
PKI and Certificate Administrators
Teams managing certificate enrollment work with DNs as the set of values supplied during creation of a CSR to identify the certificate subject. They need to ensure the subject DN aligns with what relying systems expect, since the DN is a shared identity construct spanning both directory entries and certificate subjects.
Security Architects
Architects designing identity systems that span directories and certificate infrastructure should understand the DN as a structured, hierarchical identifier whose exact syntax and ordering conventions depend on the standard profile and implementation. This informs decisions about interoperability and how identity references are passed between components.

Inside DN

Relative Distinguished Name (RDN)
A single component of a DN, typically consisting of one attribute type and value pair (for example, CN=John Smith). A DN is an ordered sequence of RDNs read from the leaf entry up toward the directory root.
Attribute Type and Value Pairs
Each RDN is built from attribute types such as CN (common name), OU (organizational unit), DC (domain component), O (organization), and C (country), each paired with a specific value. These identify the entry within its level of the directory information tree.
Ordering and Hierarchy
A DN encodes the full path to an entry through the directory information tree (DIT). The order of RDNs is significant because it reflects the hierarchical position of the entry; in most implementations the leftmost RDN is the most specific and the rightmost is closest to the root.
String Representation
DNs are commonly expressed as a comma-separated string of RDNs, as described in the LDAP string representation of distinguished names. Escaping rules typically apply to special characters such as commas, plus signs, and equals signs within attribute values.
Multi-Valued RDN
An RDN may, in some configurations, combine more than one attribute-value pair (joined with a plus sign) to uniquely identify an entry where a single attribute is insufficient.

Common questions

Answers to the questions practitioners most commonly ask about DN.

Is a Distinguished Name the same thing as a username used for authentication?
No. A DN identifies an entry within a directory information tree and serves as the unique key locating that object in the directory hierarchy. Authentication is a separate step: while an LDAP bind operation may use a DN to identify the principal being authenticated, the DN itself is an identifier, not proof of identity. In many deployments users authenticate with a friendlier attribute (such as a uid or userPrincipalName) that the directory maps to a DN behind the scenes, so treating the DN as a login credential conflates identification with authentication.
Is a DN a permanent, immutable identifier I can safely use as a primary key across systems?
Not reliably. A DN encodes an entry's position in the directory tree, so it typically changes if the object is moved, renamed, or if a parent container is restructured (a modifyDN or moveobject operation). Because the DN can change, many designs prefer a stable, location-independent identifier for cross-system correlation. Depending on the directory, an attribute intended to be immutable may be more appropriate as a durable key, whereas the DN is best treated as the current path to an entry rather than a permanent identifier.
How do I construct a DN correctly from its relative components?
A DN is typically built as a sequence of relative distinguished names (RDNs) ordered from the specific entry up through its parent containers, conventionally written most-specific-first (for example, an entry RDN followed by organizational unit and domain components). Each RDN is an attribute-value pair, and multi-valued RDNs join pairs with a plus sign. Exact attribute types, ordering conventions, and separators depend on the directory and the schema in use, so validate against your specific directory's expectations rather than assuming a universal format.
How should I handle special characters in DN values?
DN string representations reserve certain characters (such as commas, plus signs, equals signs, and others) that must be escaped when they appear within an attribute value, otherwise the DN may be parsed incorrectly. Most directory client libraries provide functions to escape or build DNs safely, and using them is generally preferable to manual string concatenation. The precise escaping rules and any additional restrictions depend on the directory implementation and the string-representation profile it follows.
What happens to references that point to a DN when the underlying entry is moved or renamed?
Because the DN reflects tree position, moving or renaming an entry typically changes its DN, and any stored references that hard-code the old DN can become stale. Some directories offer referential integrity features that update DN-valued references automatically when an entry changes, but availability and behavior vary by product and configuration. Where such features are absent, you generally need to account for DN changes in your integration logic or avoid storing DNs as long-lived references.
Should I match or compare DNs as case-sensitive strings?
DN comparison is generally more nuanced than raw string equality. Matching typically depends on the matching rules defined for each attribute in the schema, so some components may compare case-insensitively while others do not, and whitespace handling can also differ. Relying on a plain string comparison can produce false mismatches; where correct comparison matters, use directory-provided normalization or DN-aware comparison routines whose exact behavior depends on the directory and its schema.

Common misconceptions

A DN is a username used to authenticate a user.
A DN is an identifier that names and locates an entry within a directory's hierarchy (identification), not a credential. In an LDAP bind, a DN may be used to identify which entry is authenticating, but the DN itself does not verify identity; authentication still depends on a separate credential such as a password. Identification and authentication remain distinct steps.
A DN is a permanent, immutable identifier for an entry.
Because a DN encodes an entry's position in the directory tree, it can change if the entry is moved or renamed (for example, moved to a different OU). Depending on the deployment, a separate stable identifier may be preferred when a persistent reference is required.
DN component order can be written in any sequence.
The ordering of RDNs is meaningful and reflects the hierarchical path through the directory information tree. Reversing or reordering the components typically changes or invalidates the referenced entry.

Best practices

Treat the DN as an identification and location construct, and keep it separate from authentication credentials; do not rely on a DN alone to prove who a principal is.
Apply correct escaping for special characters (such as commas, equals signs, and plus signs) in attribute values to avoid ambiguous or malformed DNs.
Where a stable long-term reference is needed, avoid depending on the DN, since moving or renaming an entry can change it; consider a separate persistent identifier depending on your directory's capabilities.
Preserve and validate RDN ordering when constructing or parsing DNs, because the sequence encodes the entry's hierarchical position.
Design the directory information tree structure (OU, DC, and related components) deliberately up front, since it directly shapes the DNs of all entries beneath it.
Verify DN handling behavior against your specific directory implementation and profile rather than assuming uniform behavior across vendors, as details such as multi-valued RDN support may vary by configuration.
Application Security Isn’t Optional Anymore.