skip to content

Schema & Object Classes

Object classes and attribute types, with their MUST and MAY lists, decide what an entry may hold; standard schemas such as inetOrgPerson supply most of it. A schema violation refuses the write.

on this pageshow

explore

questions

5

In LDAP, what does a directory entry's objectClass attribute declare, and why must every entry carry one?

level: juniorimportance: must knowfreq 52%

answer

  1. an entry declares what it is
  2. the declaration is itself an attribute
  3. multi-valued, includes the superclass chain
  4. classes carry MUST and MAY lists
  5. objectClassViolation (65) refuses the write

basics

~20 s

A directory entry's objectClass attribute names the classes the entry belongs to, and those classes' MUST and MAY lists decide which attributes it may hold. The abstract class top requires the attribute, so every entry carries it.

solid answer

~40 s

Every directory entry carries a multi-valued `objectClass` attribute naming the object classes it belongs to: its structural class, that class's superclasses up to `top`, and any auxiliary classes added to it. Each of those classes publishes a `MUST` list and a `MAY` list of attribute types, and the union of those lists is exactly what the entry is allowed to hold. A missing `MUST` attribute, or an attribute in neither list, is refused with `objectClassViolation (65)`. The attribute is mandatory because `top` is an `ABSTRACT` class whose own `MUST` list contains `objectClass`, and every structural chain is rooted at `top`. The check runs in the directory server, so it holds for every client whatever the application believes it is sending.

code

ldif · 8 lines
ldif
dn: cn=Ada Lindqvist,ou=musicians,o=Northfield Sinfonia
objectClass: top
objectClass: person
objectClass: organizationalPerson
cn: Ada Lindqvist
sn: Lindqvist
telephoneNumber: +46 8 555 0142
description: principal second violin

go deeper

for a junior

Recall that objectClass is an ordinary multi-valued attribute on the entry and that its values decide which other attributes the entry may hold. Being able to read an entry and say what kind of thing it is counts at this level.

for a middle

Explain the mechanics: the declared classes plus their superclasses contribute MUST and MAY lists, the union is the permitted set, and a violation is refused by the server with a result code rather than quietly corrected.

for a senior

Show that you treat the directory server as the enforcement point. Applications that validate entries themselves and never see the server's verdict drift apart over time; the published schema is the one rule every client shares.

for a principal

The judgment is how much of a shared data model you commit to a schema the whole estate is held to. A tight schema refuses bad writes and constrains every consumer; a loose one moves that cost onto every reader instead.

## The attribute that decides the other attributes An LDAP directory entry is a Distinguished Name plus a set of attributes, each attribute holding one or more values. One of those attributes is not ordinary data: `objectClass`. It is multi-valued, it is present on every entry, and its values are the names of the object classes the entry belongs to. A directory server does not read it as information about the person or group the entry describes — it reads it as the entry's own declaration of what kind of thing it is, and every other schema decision follows from that declaration. The requirement is built into the schema rather than bolted on beside it. The class `top` (2.5.6.0) is `ABSTRACT` and carries `objectClass` in its own `MUST` list, and every structural class chain is rooted at `top`. So the one attribute that decides which attributes are permitted is itself required everywhere. There is no entry without it and no way to switch the mechanism off for one entry. ## What an object class definition carries A class is published as a definition with a numeric OID, a `NAME`, a kind, a `SUP` clause naming its superclasses, and two lists of attribute types: - **`MUST`** — attribute types the entry is required to hold. An entry lacking one is not stored. - **`MAY`** — attribute types the entry is permitted to hold. Present or absent, the server does not mind. - **`SUP`** — the superclass or superclasses whose `MUST` and `MAY` lists are inherited. - **kind** — `STRUCTURAL`, `AUXILIARY` or `ABSTRACT`, which decides how the class may be used. The worked definition to keep in mind is `person (2.5.6.6)`: `MUST ( sn $ cn )` and `MAY ( userPassword $ telephoneNumber $ seeAlso $ description )`. An entry declaring `person` must carry a surname and a common name, may carry any of the four optional types, and may carry nothing else from the user attributes unless another declared class allows it. ## Combining the lists An entry usually declares several classes, and their contributions combine rather than compete: | Input | How it contributes | Effect on the entry | |---|---|---| | the structural class | its own `MUST` and `MAY` | fixes what the entry is | | each superclass via `SUP` | inherited `MUST` and `MAY` | why `top` and `person` both appear in the values | | each auxiliary class | additional `MUST` and `MAY` | widens the entry without changing its kind | | the union of all of them | the effective permitted set | anything outside it is refused | No class overrides another and there is no precedence order among the values of `objectClass`. Whatever any declared class requires is required; whatever any declared class permits is permitted. ## What the server checks when the entry is written 1. It collects every class named in `objectClass`, plus their superclasses. 2. It unions their `MUST` and `MAY` lists into the effective permitted set. 3. Every attribute type in the effective `MUST` must be present, or the write is refused with `objectClassViolation (65)`. 4. Every user attribute supplied must appear in the effective `MUST` or `MAY`, or the write is refused with the same code. 5. Each attribute type supplied must be defined in the server's schema at all, otherwise `undefinedAttributeType (17)`, and each value must satisfy that type's syntax, otherwise `invalidAttributeSyntax (21)`. When a write breaks more than one of these, which failure the server reports first is not fixed by the protocol, so a diagnostic message naming one problem does not promise the entry has only that one. ## Operational attributes sit outside the lists Not everything on an entry is governed by `MUST` and `MAY`. Operational attributes are maintained by the directory server itself and are exempt: `creatorsName`, `createTimestamp`, `modifiersName`, `modifyTimestamp`, `entryUUID (1.3.6.1.1.16.4)`, `entryDN (1.3.6.1.1.20)` and `subschemaSubentry (2.5.18.10)` among them. They are also excluded from the default result set, so a client that reads an entry and asks for everything gets the user attributes only; the operational ones must be named in the request. ## Why the check lives in the server The practical value of the arrangement is that the rules are in one place and every client gets the same ones. An application that validates its own fields and then writes is enforcing its own opinion; the directory server enforces the estate's. That is why a schema violation is a refusal rather than a warning, and why deleting an inconvenient `objectClass` value is not a way to loosen the rules — it changes what the entry claims to be, which is exactly the thing the server is checking.

  • Which attributes may appear on a directory entry even though no object class lists them?
    Operational attributes the directory server maintains — `creatorsName`, `createTimestamp`, `modifiersName`, `modifyTimestamp`, `entryUUID (1.3.6.1.1.16.4)` and `subschemaSubentry (2.5.18.10)` among them. They are not user attributes, so `MUST` and `MAY` lists do not govern them, and a client that wants them must name them in its request because they are left out of the default result set.
  • Why does top appear among an entry's objectClass values at all?
    `top` (2.5.6.0) is the `ABSTRACT` class every structural chain is rooted at, and its `MUST` list contains `objectClass` itself. Its presence is the chain being spelled out to the root. It contributes nothing else, and it can never be an entry's own kind, because an `ABSTRACT` class exists only to be inherited from.

saying these in an interview costs you the question

  • Calls objectClass a label the application interprets however it likes.
  • Thinks an entry can hold any attribute the client chooses to send.
  • Says client-side validation is what keeps directory entries well formed.
  • Assumes one objectClass value is enough, without the superclass chain.
  • Confuses the entry's object classes with its Distinguished Name components.
open as a page

In LDAP schema, how do STRUCTURAL and AUXILIARY object classes differ in what a directory entry declares?

level: middleimportance: must knowfreq 45%

basics

~20 s

A directory entry belongs to exactly one structural object class chain, rooted at the abstract class top, and that chain says what the entry is. Auxiliary classes are added in any number and only widen the attributes it may hold.

open as a page

Beyond MUST and MAY lists, what does an LDAP attribute type definition constrain about the values an entry stores?

level: middleimportance: should knowfreq 34%

basics

~20 s

Object classes say which attribute types may appear; the attribute type definition constrains each value. SYNTAX fixes the form, EQUALITY decides when two values are the same, SINGLE-VALUE caps the count, and NO-USER-MODIFICATION reserves the attribute to the server.

open as a page

In LDAPv3, where does a directory server publish the object class and attribute type definitions it enforces?

level: middleimportance: should knowfreq 30%

basics

~10 s

A directory server publishes its schema as an ordinary entry, the subschema subentry. Each entry's operational attribute subschemaSubentry holds that subentry's Distinguished Name, and the subentry carries objectClasses, attributeTypes, matchingRules and the rest.

open as a page

A team adds extensibleObject to its directory entries so new attributes need no schema change — what does that cost?

level: seniorimportance: should knowfreq 26%

basics

~20 s

extensibleObject is an auxiliary class letting an entry hold any user attribute the schema defines, so MUST and MAY lists stop constraining it. The cost is that the server can no longer refuse a misspelled or misplaced attribute, and the entry stops being self-describing.

open as a page