Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 38 ยท Directory Concepts

The LDAP and Active Directory Schema

Understand the directory schema: attribute types, syntaxes, OIDs, matching rules, how to read schema definitions and how Active Directory schema extension works.

The schema is the rulebook of a directory. It lists every object class and attribute type the server knows, which syntax each attribute uses, how values are compared and which attributes each class requires. The previous lesson showed schema rules at work; this lesson looks at the schema itself: how definitions are written, how to read them and what it takes to extend them.

You will see real definitions in the text format used by RFC 4512, practise parsing one with a Python stand-in and learn the differences between how OpenLDAP and Active Directory store their schemas.

What the schema contains

The schema consists of several kinds of definitions:

Element What it defines
Attribute types Name, syntax, matching rules, single or multi-valued
Object classes MUST and MAY attributes, superclass, kind
Syntaxes Kinds of data: Directory String, Integer, Boolean, Octet String, ...
Matching rules How to compare for equality, ordering and substring
Content rules / DIT structure rules Optional constraints on entries and the tree

Every definition is identified by an OID (object identifier), a globally unique dotted number such as 2.5.4.3 for cn. Names are friendly aliases, but OIDs are the real identity. Organizations that add their own attributes must use an OID from a range they own (for example under the IANA Private Enterprise Number arc 1.3.6.1.4.1.<your-number>), never made-up numbers.

Schema ingredients

Attribute types Names, syntax, matching.
Object classes MUST and MAY lists.
OIDs Globally unique identities.
Matching rules How values compare.

Clients can read it from the server

1 / 2

Reading an attribute type definition

Here is the standard definition of cn, written in the RFC 4512 text format:

TEXT
( 2.5.4.3 NAME ( 'cn' 'commonName' )
  DESC 'RFC4519: common name(s) for which the entity is known by'
  SUP name )

And a more complete one, the definition of mail:

TEXT
( 0.9.2342.19200300.100.1.3 NAME ( 'mail' 'rfc822Mailbox' )
  DESC 'RFC1274: RFC822 Mailbox'
  EQUALITY caseIgnoreIA5Match
  SUBSTR caseIgnoreIA5SubstringsMatch
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

The keywords:

  • NAME: one or more names.
  • SUP: the parent attribute type it inherits from (so cn inherits properties from name).
  • EQUALITY, ORDERING, SUBSTR: matching rules for exact, ordered and substring searches.
  • SYNTAX: an OID naming the syntax; is an optional maximum length.
  • SINGLE-VALUE: only one value allowed.
  • USAGE: userApplications (default) or an operational usage such as directoryOperation.
  • NO-USER-MODIFICATION: clients cannot write it.

An object class definition looks similar:

TEXT
( 2.5.6.6 NAME 'person'
  SUP top STRUCTURAL
  MUST ( sn $ cn )
  MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )

SUP gives the superclass, STRUCTURAL the kind, MUST and MAY the attribute lists separated by $.

Parsing a definition (Python stand-in)

The stand-in below parses the object class definition above into a Python structure. It uses a regular expression, which is good enough for well-formed examples. Real servers use a proper grammar. A second block then prints the full list of required attributes by following the chain.

Python Parse an objectClass definition

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.

Python Resolve inherited MUST attributes

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.

Discovering the schema from a server

LDAP makes the schema self-describing. The server exposes a special entry, the subschema subentry, whose DN is listed in the Root DSE attribute subschemaSubentry. Reading it returns attributeTypes, objectClasses, ldapSyntaxes and matchingRules:

Terminal
ldapsearch -x -H ldap://localhost -s base -b "" subschemaSubentry
ldapsearch -x -H ldap://localhost -s base -b "cn=Subschema" objectClasses attributeTypes

On Active Directory the subschema entry is cn=Aggregate,cn=Schema,cn=Configuration,dc=corp,dc=example,dc=test, and the real schema is stored as objects (classes classSchema and attributeSchema) under cn=Schema,cn=Configuration. Each class or attribute is itself an entry you can inspect with ADSI Edit or Get-ADObject.

Extending the schema

Sometimes you need a new attribute, for example employeeBadgeNumber. The workflow:

  1. Check whether a standard attribute already fits (employeeNumber, employeeID). Reusing standards is always safer.
  2. Obtain an OID under an arc you own.
  3. Define the attribute type, then add it to an existing auxiliary class or create a new auxiliary class that carries it.
  4. Load it into a test server first.

In OpenLDAP you write an LDIF with a cn=schema,cn=config entry using olcAttributeTypes and olcObjectClasses. In Active Directory you use the Active Directory Schema snap-in (registered with regsvr32 schmmgmt.dll) or an LDIF file loaded with ldifde -i. The Schema Master (see Global Catalog and FSMO Roles) must be reachable, and you need membership in the Schema Admins group.

Schema changes in Active Directory are forest-wide and permanent. You can mark an attribute or class defunct (deactivate it), but you can never truly delete it or reuse its OID or lDAPDisplayName. Always test in a lab, take a system state backup and keep Schema Admins empty except while you work.

Schema design tips

  • Prefer auxiliary classes for new attributes so existing entries can adopt them without changing their structural class.
  • Name attributes with a company prefix (such as exampleBadgeNumber) to avoid collisions with future standard attributes.
  • Choose the right syntax: integers for numbers, so ordering searches (>=) work numerically.
  • Mark attributes single-valued when more than one value makes no sense.
  • Document every extension with its OID and purpose.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What uniquely identifies an attribute type or object class in the schema?

    Names are aliases; the dotted OID is the globally unique identity.
  2. 2. What does SUP mean in a schema definition?

    SUP names the superclass or parent attribute type.
  3. 3. Why is a schema extension in Active Directory risky?

    AD schema changes replicate to the whole forest and are permanent, so test first.
  4. 4. Where does a client find the DN of the schema entry on a standard LDAP server?

    The Root DSE lists subschemaSubentry, whose entry holds attributeTypes and objectClasses.

Summary

  • The schema defines attribute types, object classes, syntaxes and matching rules, each identified by an OID.
  • Definitions use the RFC 4512 text format with keywords like NAME, SUP, MUST, MAY, SYNTAX.
  • Servers publish the schema themselves via the subschema subentry.
  • Extend with your own OID arc, prefer auxiliary classes, and test first.
  • In Active Directory, schema changes are forest-wide and can only be deactivated, never removed.

Next: Distinguished Names