You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Add your first elements to the schema

This section shows how to define custom schema elements, and how to add them to an ApacheDS 1.5.0 instance.

Motivation

The schema of an LDAP server is comprised of object classes, attributes, syntaxes and matching rules. Basically it defines which entries are allowed within the server and how the server should handle them. In contrast to the 1.0 release, ApacheDS 1.5.0 comes with a completely redesigned schema subsystem. It allows to dynamically update the schema, for instance it is possible to create new attribute types or object classes on the fly, i.e. without restarting the server.

Newbie question: Is it always necessary to define my own schema elements?

No. ApacheDS comes with a comprehensive set of predefined, standardized schema elements (like inetOrgPerson). It is quite common to solely use the predefined schema. The same holds true for other directory servers, by the way.

In the following text the addition of user defined schema elements to the schema is described in tutorial style.

Browsing the schema of ApacheDS

LDAPv3 servers publish their schema via LDAP. Thus it is possible to list the schema elements with standard LDAP tools. For instance it is possible to use the ldapsearch command line tool to list all object classes

$ ldapsearch -h zanzibar -p 10389 -D "uid=admin,ou=system" -w ****** \
     -b "cn=schema" -s base "(objectclass=subschema)" objectclasses
...
objectClasses: ( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top 
  STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ 
  seeAlso $ description ) X-SCHEMA 'core' )
...

The output contains all things which are interesting to know about an object class (required attributes, optional attributes etc.), but is not easy to read by a human user.

It is therefore often appropriate to use a GUI tool to browse the schema (which basically performs the same search operations but presents the output prettily). One option is Apache Directory LDAP Studio, an Eclipse based LDAP tool set which contains a powerful graphical Schema browser:

The ability to browse the schema is outlined here, because with this we have an solid way to check whether our changes to the schema took please.

A simple example

The goal is to add ship entries to our directory, backing the "Seven Seas" example used throughout the Basic User's Guide. Here is a sample entry in LDIF:

dn: cn=HMS Victory,ou=ships,o=sevenSeas
objectClass: top
objectClass: ship
cn: HMS Victory
numberOfGuns: 104
description: a ship of the line of the Royal Navy, built between 1759 and 1765

A new attribute type and a new object class have to be added to the schema.

attribute type numberOfGuns

object class ship

Which OIDs should I use?

Using LDIF to define and load the new schema elements

Using JNDI to add the schema elements programatically

  • No labels