Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 38 ยท Directory Concepts

Entries, Attributes and Object Classes

Learn how an LDAP entry is built from attributes, how object classes (structural, auxiliary, abstract) control what is allowed, and how to read common person entries.

Every piece of data in a directory lives in an entry. An entry is a bag of attributes, and the entry's object classes decide which attributes it must have and which it may have. These three ideas (entry, attribute, object class) are the vocabulary for everything else in LDAP, so it is worth getting them exactly right.

By the end of this lesson you will be able to read an entry written in text form, say which attributes are required, explain why attributes can have several values and use a Python stand-in to check an entry against a small set of object class rules.

Anatomy of an entry

Here is a typical person entry as an LDAP client would display it (the LDIF format is covered in LDIF):

LDIF
dn: uid=asmith,ou=People,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
uid: asmith
cn: Alice Smith
sn: Smith
givenName: Alice
mail: [email protected]
mail: [email protected]
telephoneNumber: +1 555 0100
title: Senior Engineer

Read it line by line:

  • dn is the entry's unique name, not technically an attribute.
  • Four objectClass lines list the classes the entry belongs to.
  • Every other line is attribute: value. A line repeats when an attribute has several values: this entry has two mail values.

An attribute has a name (such as cn), a syntax (what kind of data it holds: text, integer, boolean, binary) and matching rules (how values are compared during a search, for example case-insensitively). Attribute names are case-insensitive: mail, Mail and MAIL are the same.

The building blocks

Entry One thing in the directory.
Attribute A named, possibly multi-valued fact.
Object class Rules for allowed attributes.

Entry = DN + object classes + attributes

1 / 2

Single and multi-valued attributes

Some attributes hold exactly one value (uid, userPassword in most designs), others many (mail, telephoneNumber, memberOf, objectClass). The schema marks the attribute as SINGLE-VALUE or not. Order among values is not guaranteed, and values within one attribute must be distinct under the matching rule.

Object classes

An object class is a template. It names:

  • a set of MUST attributes the entry must have,
  • a set of MAY attributes it can have,
  • the class it inherits from (its superclass).

Classes form an inheritance chain. inetOrgPerson inherits from organizationalPerson, which inherits from person, which inherits from top. Inheriting means the entry also needs the MUST attributes of every ancestor. For example, person requires sn and cn; inetOrgPerson adds many optional ones such as mail, givenName, uid and title.

Three kinds of object class

Kind Purpose Example
Structural Defines what the entry is. Every entry has exactly one structural class chain. inetOrgPerson, organizationalUnit, groupOfNames
Auxiliary Adds extra attributes to an existing entry. Can be combined freely. posixAccount, shadowAccount
Abstract Only for inheritance. Cannot be used directly. top

The rule: pick one structural class (a chain) and optionally add auxiliary classes. A person who also logs in to Linux machines gets inetOrgPerson (structural) plus posixAccount (auxiliary) which adds uidNumber, gidNumber, homeDirectory and loginShell.

Some classes you will meet often

Class Used for MUST attributes
organizationalUnit Containers ou
person Basic person sn, cn
inetOrgPerson Internet-era person (mail, uid) same as person
groupOfNames Group with member DNs cn, member
groupOfUniqueNames Variant that prevents duplicate DNs cn, uniqueMember
posixGroup Unix group cn, gidNumber
device Network device cn

Active Directory uses its own set: user, computer, group, organizationalUnit, contact. An AD user has a long chain: top > person > organizationalPerson > user. You will meet it in Users, Computers and Groups.

Operational attributes

Besides ordinary user attributes, servers maintain operational attributes that clients do not set directly: createTimestamp, modifyTimestamp, entryUUID (OpenLDAP) or whenCreated, objectGUID, uSNChanged (Active Directory). They are normally hidden unless you ask for them with + (OpenLDAP) or by name.

Common attribute names

Short names come from X.500 and survive today:

Name Long form Meaning
cn commonName Full or common name
sn surname Family name
givenName First name
uid userid Login name
mail Email
ou organizationalUnitName Container name or a person's department
o organizationName Organization
dc domainComponent A DNS label
l, st, c locality, state, country Place
member DN of a group member

An attribute can have several names: cn and commonName are aliases. Use the short form by convention.

Checking an entry against its classes (Python stand-in)

A server validates every add and modify against the schema. This stand-in implements the core check with a tiny hand-written schema: are all MUST attributes present, and is every attribute allowed by at least one of the entry's classes?

Python Schema check for an entry (stand-in)

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 the last case: person alone does not allow mail. You would have to use inetOrgPerson, exactly the kind of error a real server reports as objectClassViolation.

Multi-valued attributes in practice

Run a quick experiment on how values behave. Servers compare values using the attribute's matching rule; for mail that means case-insensitive, so adding [email protected] when [email protected] exists is a duplicate.

Python Case-insensitive matching

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.

Exact matching rules matter: caseIgnoreMatch ignores case, caseExactMatch does not, integerMatch compares numbers. A search for (cn=alice smith) finds Alice Smith only because cn uses a case-insensitive rule.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What must every entry have besides a DN?

    Every entry has objectClass values, which determine the MUST and MAY attributes.
  2. 2. What is the role of an auxiliary object class?

    Auxiliary classes such as posixAccount add attributes to an existing structural entry.
  3. 3. An entry uses objectClass person and has a mail attribute. What happens?

    mail is allowed by inetOrgPerson, not by person. Add the right class or remove the attribute.
  4. 4. Why can an attribute such as mail appear several times in an entry?

    Multi-valued attributes hold several distinct values.

Summary

  • An entry is a DN plus object classes plus attributes; attributes may have several values.
  • Object classes define MUST and MAY attributes and form an inheritance chain ending at top.
  • Entries have one structural class chain and any number of auxiliary classes.
  • Operational attributes are maintained by the server, not by clients.
  • Attribute matching rules decide how values compare in searches and duplicates.

Next: The LDAP Schema