Skip to content

What is the Difference Between DN and RDN?

4 min read

In directory services like LDAP, a Distinguished Name (DN) serves as a unique identifier for an object, while its core component, the Relative Distinguished Name (RDN), provides a localized name. The crucial difference between DN and RDN lies in their scope: one offers a complete hierarchical address, and the other provides a relative, unique part within a specific container.

Quick Summary

A Distinguished Name (DN) is the absolute, unique path to an entry in a directory tree, while a Relative Distinguished Name (RDN) is a single, unique component of that path, specific to its parent entry.

Key Points

  • Absolute vs. Relative: A DN is a unique absolute path to a directory entry, while an RDN is a unique name relative to its parent container.

  • Hierarchical Structure: A DN is built from a sequence of RDNs, starting with the object's own RDN and ascending the directory tree.

  • Uniqueness Scope: A DN is unique across the entire directory, whereas an RDN is only unique within the context of its parent.

  • Attribute-Value Pairs: An RDN consists of one or more attribute=value pairs (e.g., cn=John Doe), while a DN is a collection of these RDNs.

  • Analogy: Think of a DN as a full file path (C:\folder\file.txt) and an RDN as just the filename (file.txt).

  • Practical Application: DNs are used for absolute lookups and authentication, while RDNs are involved in the renaming of an object within the directory.

In This Article

Understanding Directory Names: DN vs. RDN

For anyone working with directory services such as Lightweight Directory Access Protocol (LDAP) or Microsoft's Active Directory, navigating the naming conventions is crucial. The terms Distinguished Name (DN) and Relative Distinguished Name (RDN) are foundational concepts that define how objects are located and managed within the directory's hierarchical structure. While often used in the same context, they represent distinct levels of specificity in the directory tree.

What is a Distinguished Name (DN)?

A Distinguished Name, or DN, is a unique identifier that specifies the complete, absolute path to an entry in a directory information tree (DIT). Think of it as the full street address for a house, including the house number, street, city, state, and country. This complete path ensures that every entry—whether it's a user, a group, or a device—can be located unambiguously.

An LDAP DN is constructed by listing the names of all the parent entries, from the specific object all the way up to the root of the directory. These components are separated by commas. For example, the DN for a user named "Jane Doe" in the "Marketing" department of the "example.com" domain might be:

cn=Jane Doe,ou=Marketing,dc=example,dc=com

This DN provides a clear, hierarchical context, showing that the user cn=Jane Doe is located within the organizational unit ou=Marketing, which in turn is part of the domain components dc=example and dc=com.

What is a Relative Distinguished Name (RDN)?

In contrast, a Relative Distinguished Name, or RDN, is a single component of a DN. It is the unique identifier of an entry relative to its parent. Continuing the street address analogy, an RDN is like the house number on a specific street. While several houses might have the same number, they are only unique on their respective streets. Similarly, an RDN must be unique only within its parent container.

An RDN is typically composed of one or more attribute=value pairs. In our example DN above, the RDN for the user is cn=Jane Doe. This specific RDN is only unique within the ou=Marketing container. Another cn=Jane Doe could exist in a different organizational unit, like ou=Sales, as long as its full DN is different.

RDNs can also contain multiple attribute-value pairs, separated by a plus sign (+). This is useful in scenarios where a single attribute might not be unique enough within a container. A multivalued RDN might look like cn=John Smith+studentNumber=123456, ensuring uniqueness in a large university directory.

DN vs. RDN Comparison Table

Feature Distinguished Name (DN) Relative Distinguished Name (RDN)
Purpose Uniquely identifies an entry within the entire directory tree. Uniquely identifies an entry relative to its immediate parent.
Scope Global (entire directory). Local (within its parent container).
Composition A full path of comma-separated RDNs. A single attribute-value pair or multiple pairs separated by a plus sign.
Example cn=Jane Doe,ou=Marketing,dc=example,dc=com cn=Jane Doe
Uniqueness Must be unique throughout the entire directory. Must be unique only within its parent container.
Analogy A complete file path like /home/user/document.txt The filename document.txt

How DNs and RDNs Work Together

The relationship between a DN and RDN is foundational to how directory services operate. A DN is built from a sequence of RDNs, with the most specific RDN (that of the entry itself) listed first, followed by the RDN of its parent, and so on, up to the root. For instance, starting with the RDN cn=Jane Doe, you append the parent's RDN ou=Marketing to form cn=Jane Doe,ou=Marketing. You then append the next parent's RDNs dc=example,dc=com to form the full DN. This hierarchical construction allows for efficient lookups and management of directory entries.

For example, when an LDAP client authenticates, it might use the user's full DN and password to bind to the directory server. Similarly, when performing a search operation, a DN can be used as a search base to specify where the query should begin, restricting the scope of the search to a specific subtree.

Importance in Directory Management

The clear distinction between DN and RDN is vital for several directory management tasks:

  • Moving an object: When an entry is moved to a different container, its RDN may not change, but its full DN will, as the path to its parent has been altered. For example, moving a user from ou=Marketing to ou=Sales would change their DN from cn=Jane Doe,ou=Marketing,... to cn=Jane Doe,ou=Sales,....
  • Renaming an object: If you rename an object, such as changing a user's common name (cn), you are effectively changing the object's RDN. This automatically results in a new DN for the object, even if its position in the hierarchy remains the same.
  • Performance: Understanding the hierarchy represented by a DN helps in optimizing search queries. By providing a specific DN as a base, administrators can reduce the scope of a search and improve performance.

Conclusion

The difference between a Distinguished Name (DN) and a Relative Distinguished Name (RDN) is a matter of scope and hierarchy. The DN provides the complete, unambiguous path to an entry from the directory root, guaranteeing its uniqueness. The RDN, conversely, is a single, relative component of that DN, uniquely identifying the entry within its immediate parent container. By understanding this core relationship, IT professionals can more effectively manage, locate, and manipulate objects within directory services like LDAP and Active Directory. The DN is the full address, while the RDN is the name at the door.

For further reading, the comprehensive guide on LDAP DNs and RDNs from LDAP.com is an excellent resource.

Frequently Asked Questions

Yes, an RDN can be the same for two different objects, provided those objects are in different containers. For example, two users in different organizational units could both have the RDN cn=John Smith.

The leftmost component of a DN is the RDN of the specific entry itself. The DN is constructed by concatenating the entry's RDN with its parent's DN.

A multivalued RDN is a relative distinguished name that contains more than one attribute-value pair. These pairs are separated by a plus sign (+), and are used to ensure uniqueness when a single attribute is not sufficient.

When a user logs into an LDAP-enabled application, they often provide their full DN along with their password. The directory server uses this unique DN to find the correct user object and verify their credentials.

When a user is moved to a new organizational unit (OU), their full DN changes to reflect the new hierarchical path. However, their specific RDN, such as their common name, typically remains the same.

Unlike a filesystem path that often goes down from the root, an LDAP DN is written from the specific entry up towards the directory root. For example, the most specific part is on the left, and the root is on the right.

No, the RDN is not always the common name. While cn is a very common attribute for an RDN, other attributes like uid (user ID) or mail can also be used, depending on the directory schema.

References

  1. 1
  2. 2
  3. 3
  4. 4

Medical Disclaimer

This content is for informational purposes only and should not replace professional medical advice.