Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 38 ยท Directory Concepts

The Directory Information Tree (DIT)

Learn how LDAP arranges entries in a hierarchy called the Directory Information Tree, what root, base DN, suffix, parents and children mean, and how to design one.

An LDAP directory is not a flat list. Entries are arranged in a tree, called the Directory Information Tree (DIT). The tree gives every entry a place, makes it easy to apply rules to a whole branch (for example, "everything under Sales") and lets servers split data across machines by branch.

This lesson explains the vocabulary of the tree: root, suffix, base, parents and children, leaf and container entries. It then shows a common way to design a tree and lets you build and print one with a Python stand-in.

A tree of entries

Suffix Top of your data, like dc=example,dc=com.
Containers Branches such as ou=People.
Leaves Individual users, groups, devices.

Every entry has exactly one parent

1 / 2

The shape of the tree

Picture a company directory:

TEXT
dc=example,dc=com
โ”œโ”€โ”€ ou=People
โ”‚   โ”œโ”€โ”€ uid=asmith
โ”‚   โ”œโ”€โ”€ uid=bjones
โ”‚   โ””โ”€โ”€ uid=cwu
โ”œโ”€โ”€ ou=Groups
โ”‚   โ”œโ”€โ”€ cn=engineers
โ”‚   โ””โ”€โ”€ cn=sales
โ””โ”€โ”€ ou=Printers
    โ””โ”€โ”€ cn=hq-laser-1
  • The top entry dc=example,dc=com is the suffix (also called the naming context). It is the root of the data this server holds.
  • ou=People, ou=Groups and ou=Printers are containers. They exist to group other entries.
  • uid=asmith and the rest are leaf entries: they have no children.

Strictly speaking the LDAP tree has an invisible root DSE above all naming contexts. The Root DSE is a special entry with an empty DN that describes the server itself (which naming contexts it holds, which LDAP versions and extensions it supports). You read it by searching with an empty base and scope base.

Key terms

Term Meaning
Entry One node in the tree, with attributes
Parent / child An entry directly above or below another
Ancestor / descendant Any entry above or below, at any depth
Sibling Entries sharing the same parent
Suffix / naming context The topmost entry of a branch a server holds
Base DN The entry where a particular search starts
Subtree An entry plus all of its descendants
Leaf An entry with no children

The tree enforces a rule: an entry cannot exist unless its parent exists. You must create ou=People before uid=asmith,ou=People,dc=example,dc=com. In the other direction, you cannot delete an entry that still has children (an LDAP delete on a non-leaf fails with notAllowedOnNonLeaf).

Choosing a suffix

Two styles are common:

  1. Domain components: dc=example,dc=com, derived from the DNS name. This is the style AD uses and the most widespread one. example.com becomes dc=example,dc=com.
  2. Organization and country: o=Example Inc,c=US, the older X.500 style.

Prefer the DNS-based style: your DNS name is unique and everyone understands it.

Designing the layout

Use this checklist:

  • Keep it shallow. Three or four levels is typical. A deep tree makes names long and forces moves when the organization changes.
  • Group by object type or by purpose, not by org chart. If you put people under ou=Sales, then a user who changes departments has to be moved, which changes their DN and breaks every group membership that pointed at the old name. Many designs keep people in one flat ou=People and record the department in an attribute.
  • Separate service accounts and groups into their own containers so you can apply different access control.
  • Plan delegation. The tree is also how you grant permissions: "the helpdesk may reset passwords in ou=People". Active Directory uses OUs for exactly this and for Group Policy, so there the org-chart-like layout is common. See Organizational Units.

Never use the tree to store values that change often. Put changing facts in attributes.

Containers and object classes

A container is just an entry whose object class allows children. Common container classes are:

Class Typical RDN Notes
organizationalUnit ou=People The standard general-purpose container
organization o=Example An organization, often the top
domain or dcObject dc=example A DNS-derived node
container cn=Users Used by Active Directory for built-in folders

You will learn what object classes are in Entries, Attributes and Object Classes.

Build and print a tree (Python stand-in)

The stand-in below stores entries by DN and prints them as an indented tree. It also enforces the rule that a parent must exist and that you cannot delete a non-leaf. It does not parse DNs fully; that comes in Distinguished Names. Here a DN is split on commas, and everything after the first comma is the parent.

Python A tiny DIT

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The three error messages mirror real LDAP result codes: noSuchObject, notAllowedOnNonLeaf and entryAlreadyExists.

Counting subtrees

A search with the "subtree" scope covers an entry and everything under it. This second stand-in counts how many entries fall in each branch, which is exactly what a subtree search would return.

Python Subtree size

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that "is under" is just a string suffix test on the DN. That is one reason DNs are written with the most specific part first and the root last.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the suffix (naming context) of a directory?

    The suffix is the root of a branch held by a server, often derived from the DNS name.
  2. 2. What happens if you try to delete an entry that still has children?

    LDAP only deletes leaf entries. You must delete or move the children first.
  3. 3. Why is it risky to put people under department containers such as ou=Sales?

    Moving an entry changes its DN. Group memberships and other references that use the old DN must then be updated.
  4. 4. Which entry describes the server itself, such as its naming contexts?

    The Root DSE has an empty DN and is read with a base-scope search on the empty base.

Summary

  • The DIT is a tree of entries; each entry has one parent, except the top entries of the naming contexts.
  • The suffix is the root of a server's data; the base DN is where one search starts.
  • A parent must exist before a child, and only leaves can be deleted.
  • Prefer shallow trees organized by type or purpose, with changing facts kept in attributes.
  • The Root DSE describes the server's capabilities and naming contexts.

Next: Entries, Attributes and Object Classes