Netscape logo Deployment Guide
Netscape Directory Server

Previous      Contents      Index      DocHome      Next     

Chapter 3   How to Design the Schema


The site survey you conducted in Chapter 2 generated information abut the data you plan to store in your directory. Next, you must decide how to represent the data you store. Your directory schema describes the types of data you can store in your directory. During schema design, you map each data element to an LDAP attribute, and gather related elements into LDAP object classes. Well-designed schema help maintain the integrity of the data you store in your directory.

This chapter describes the directory schema and how to design schema for your unique needs. This chapter contains the following sections:

For information on replicating schema, refer to "Schema Replication".

Schema Design Process Overview


During schema design, you select and define the object classes and attributes used to represent the entries stored by Netscape Directory Server (Directory Server). Schema design involves the following steps:

It is best to use existing schema elements defined in the standard schema provided with Directory Server. Choosing standard schema elements helps ensure compatibility with directory-enabled applications. In addition, as the schema is based on the LDAP standard, you are assured it has been reviewed and agreed to by a wide number of directory users.

Netscape Standard Schema


Your directory schema maintain the integrity of the data stored in your directory by imposing constraints on the size, range, and format of data values. You decide what types of entries your directory contains (people, devices, organizations, and so forth) and the attributes available to each entry.

The predefined schema included with Directory Server contains both the standard LDAP schema as well as additional application-specific schema to support the features of the server. While this schema meets most directory needs, you may need to extend it with new object classes and attributes to accommodate the unique needs of your directory. Refer to "Customizing the Schema" for information on extending the schema.

The following sections describe the format, standard attributes, and object classes included in the Netscape standard schema.

Schema Format

Directory Server bases its schema format on version 3 of the LDAP protocol (LDAPv3). This protocol requires directory servers to publish their schemas through LDAP itself, allowing directory client applications to programmatically retrieve the schema and adapt their behavior based on it. The global set of schema for Directory Server can be found in the entry named cn=schema.

The Directory Server schema differs slightly from the LDAPv3 schema, as it uses its own proprietary object classes and attributes. In addition, it uses a private field in the schema entries called X-ORIGIN, which describes where the schema entry was defined originally. For example, if a schema entry is defined in the standard LDAPv3 schema, the X-ORIGIN field refers to RFC 2252. If the entry is defined by Netscape for the Directory Server's use, the X-ORIGIN field contains the value Netscape Directory Server.

For example, the standard person object class appears in the schema as follows:

objectclasses: ( 2.5.6.6 NAME 'person' DESC 'Standard Person Object  Class' SUP top MUST (objectlass $ sn $ cn) MAY (description $  seealso $ telephoneNumber $ userPassword) X-ORIGIN 'RFC 2252' )

This schema entry states the object identifier, or OID, for the class (2.5.6.6), the name of the object class (person), a description of the class (standard person), then lists the required attributes (objectclass, sn, and cn) and the allowed attributes (description, seealso, telephoneNumber, and userPassword).

For more information about the LDAPv3 schema format, refer to the LDAPv3 Attribute Syntax Definitions document (RFC2252).

The differences between Directory Server 6.x schema and Directory Server 4.x are described in the following table:

Directory Server 4.x Syntax    

Equivalent Directory Server 6.x Syntax

bin

Binary

ces

IA5String

cis

DirectoryString

dn

DN

int

INTEGER

tel

TelephoneNumber



In addition, Directory Server 6.x supports the following syntaxes:

Syntax      

Description

OctetString

Same behavior as Binary.

URI

Same behavior as IA5String.

Boolean

Boolean values have a value of either "TRUE" or "FALSE."

GeneralizedTime    

Values in this syntax are encoded as printable strings. It is strongly recommended that GMT time be used. The time zone must be specified.

CountryString

A value in this syntax is encoded the same as a value of DirectoryString syntax. Note that this syntax is limited to values of exactly two printable string characters.

PostalAddress

Values in this syntax are encoded according to the following:

postal-address = dstring *("$" dstring)

In the above, each dstring component of a postal address value is encoded as a value of type DirectoryString syntax. Backslashes and dollar characters, if they occur in the component, are quoted. Many servers limit the postal address to six lines of up to thirty characters. For example:

1234 Main St.$Anytown,TX 12345$USA



Standard Attributes

Attributes hold specific data elements such as a name or a fax number. Directory Server represents data as attribute-data pairs, a descriptive attribute associated with a specific piece of information. For example, the directory can store a piece of data such as a person's name in a pair with the standard attribute, in this case commonName (cn). So, an entry for a person named Babs Jensen has the following attribute-data pair:

cn: Babs Jensen

In fact, the entire entry is represented as a series of attribute-data pairs. The entire entry for Babs Jensen might appear as follows:

dn: uid=bjensen, ou=people, dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Babs Jensen
sn: Jensen
givenName: Babs
givenName: Barbara
mail: bjensen@example.com

Notice that the entry for Babs contains multiple values for some of the attributes. The attribute givenName appears twice, each time with a unique value. The object classes that appear in this example are explained in the next section, "Standard Object Classes."

In the schema, each attribute definition contains the following information:

For example, the cn attribute definition appears in the schema as follows:

attributetypes: ( 2.5.4.3 NAME 'cn' DESC 'commonName Standard  Attribute' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )

Standard Object Classes

Object classes are used to group related information. Typically, an object class represents a real object, such as a person or a fax machine. Before you can use an object class and its attributes in your directory, it must be identified in the schema. Your directory recognizes a standard list of object classes by default. See the Netscape Directory Server Schema Reference for more information.

Each directory entry belongs to one or more object classes. Once you place an object class identified in your schema on an entry, you are telling the Directory Server that the entry can have a certain set of attribute values and must have another, usually smaller, set of attribute values.

Object class definitions contain the following information:

For an example of a standard object class as it appears in the schema, refer to "Schema Format".

As is the case for all of the Directory Server's schema, object classes are defined and stored directly in Directory Server. This means that you can both query and change your directory's schema with standard LDAP operations.

Mapping Your Data to the Default Schema


The data you identified during your site survey, as described in "Performing a Site Survey", must be mapped to the existing directory default schema. This section describes how to view the existing default schema and provides a method for mapping your data to the appropriate existing schema elements.

If you find elements in your schema that do not match the existing default schema, you may need to create custom object classes and attributes. Refer to "Customizing the Schema" for more information.

Viewing the Default Directory Schema

The default directory schema is stored here:

serverRoot/slapd-serverID/config/schema

This directory contains all of the common schema for the Netscape products. The LDAPv3 standard user and organization schema can be found in the 00core.ldif file. The configuration schema used by earlier version of the directory can be found in the 50ns-directory.ldif file.


Note  

You should not modify the default directory schema.




For more information about each object class and attribute found in directory, refer to the Netscape Schema Reference Guide. For more information about the schema files and directory configuration attributes, refer to Netscape Directory Server Configuration, Command, and File Reference.

Matching Data to Schema Elements

The data you identified in your site survey now needs to be mapped to the existing directory schema. This process involves the following steps:

For example, the following table maps directory schema elements to the data identified during the site survey in Chapter 2:


Table 3-1    Data Mapped to Default Directory Schema  


Data

Owner

Object Class

Attribute

Employee name

HR

person

cn(commonName)

User password

IS

person

userPassword

Home phone number

HR

inetOrgPerson

homePhone

Employee location

IS

inetOrgPerson

localityName

Office phone number  

Facilities  

person  

telephoneNumber



In the table, the employee name describes a person. In the default directory schema, we found the person object class, which inherits from the top object class. This object class allows several attributes, one of which is the cn or commonName attribute, which describes the full name of the person. This attribute makes the best match for containing the employee name data.

The user password also describes an aspect of the person object. In the list of allowed attributes for the person object, we find userPassword.

The home phone number describes an aspect of a person, however we do not find an appropriate attribute in the list associated with the person object class. Analyzing the home phone number more specifically, we can say it describes an aspect of a person in an organization's enterprise network. This object corresponds to the inetOrgPerson object class in the directory schema. The inetOrgPerson object class inherits from the organizationPerson object class, which in turn inherits from the person object class. Among the inetOrgPerson object's allowed attributes, we locate the homePhone attribute, which is appropriate for containing the employee's home telephone number.

Customizing the Schema


You can extend the standard schema if it proves to be too limited for your directory needs. To help you extend your schema, the Directory Server includes a schema management tool. For more information, see Netscape Directory Server Administrator's Guide.

Keep the following rules in mind when customizing your schema:

Your custom object classes and attributes are defined in the following file:

serverRoot/slapd-serverID/config/schema/99user.ldif

The following sections describe customizing the directory schema in more detail:

When to Extend Your Schema

While the object classes and attributes supplied with the Directory Server should meet most of your needs, you may find that a given object class does not allow you to store specialized information about your organization. Also, you may need to extend your schema to support the object classes and attributes required by an LDAP-enabled application's unique data needs.

Getting and Assigning Object Identifiers

Each LDAP object class or attribute must be assigned a unique name and object identifier (OID). When you define a schema, you need an OID unique to your organization. One OID is enough to meet all of your schema needs. You simply add another level of hierarchy to create new branches for your attributes and object classes. Getting and assigning OIDs in your schema involves the following steps:

Naming Attribute and Object Classes

When creating names for new attribute and object classes, make the name as meaningful as possible. This makes your schema easier to use for Directory Server administrators.

Avoid naming collisions between your schema elements and existing schema elements by including a unique prefix on all of your elements. For example, example.com Corporation might add the prefix example before each of their custom schema elements. They might add a special object class called examplePerson to identify example.com. employees in their directory.

Strategies for Defining New Object Classes

There are two ways you can create new object classes:

You may find it easiest to mix the two methods.

For example, suppose your site wants to create the attributes exampleDateOfBirth, examplePreferredOS, exampleBuildingFloor, and exampleVicePresident. You can create several object classes that allow some subset of these attributes. You might create an object class called examplePerson and have it allow exampleDateOfBirth and examplePreferredOS. The parent of examplePerson would be inetOrgPerson. You might then create an object class called exampleOrganization and have it allow exampleBuildingFloor and exampleVicePresident. The parent of exampleOrganization would be the organization object class.

Your new object classes would appear in LDAPv3 schema format as follows:

objectclasses: ( 2.16.840.1.17370.999.1.2.3 NAME 'examplePerson'  DESC 'Example Person Object Class' SUP inetorgPerson MAY (exampleDateOfBirth  $ examplePreferredOS) )

objectclasses: ( 2.16.840.1.17370.999.1.2.4 NAME  'exampleOrganization' DESC 'Organization Object Class' SUP  organization MAY (exampleBuildingFloor $ exampleVicePresident) )

Alternatively, you can create a single object class that allows all of these attributes and use it with any entry on which you want to use these attributes. The single object class would appear as follows:

objectclasses: (2.16.840.1.17370.999.1.2.5 NAME 'exampleEntry' DESC  'Standard Entry Object Class' SUP top AUXILIARY MAY
 (exampleDateOfBirth $ examplePreferredOS $ exampleBuildingFloor $
 exampleVicePresident) )

The new exampleEntry object class is marked AUXILIARY, meaning that it can be used with any entry regardless of its structural object class.


Note  

The OID of the new object classes in the example is based on the Netscape OID prefix. To create your own new object classes, you must get your own OID. For more information, refer to "Getting and Assigning Object Identifiers".




Choose the strategy for defining new object classes that works for you. Consider the following when deciding how to implement new object classes:

After defining a new object class, you need to decide what attributes it allows and requires and from what object class(es) it inherits.

Strategies for Defining New Attributes

Add new attributes and new object classes when the existing object classes do not support all of the information you need to store in a directory entry.

Try to use standard attributes whenever possible. Search the attributes that already exist in the default directory schema and use them in association with a new object class. Create a new attribute if you cannot find a match in the default directory schema.

For example, you may find that you want to store more information on a person entry than the person, organizationalPerson, or inetOrgPerson object classes support. If you want to store the birth dates in your directory, no attribute exists within the standard Directory Server schema. You can choose to create a new attribute called dateOfBirth and allow this attribute to be used on entries representing people by defining a new auxiliary class, examplePerson, which allows this attribute.

Deleting Schema Elements

Do not delete the schema elements shipped with Directory Server. Unused schema elements represent no operational or administrative overhead. However, by deleting parts of the standard LDAP schema you may run into compatibility problems with future installations of Directory Server and other directory-enabled applications.

However, if you extend the schema and find you do not use the new elements, feel free to delete the elements you don't use. Before removing the object class definitions from the schema, you need to modify each entry using the object class. Otherwise, if you remove the definition first, you might not be able to modify the entries that use the object class afterwards. Schema checks on modified entries will also fail unless you remove the unknown object class values from the entry.

Creating Custom Schema Files

You can create custom schema files other than the 99user.ldif file provided with Directory Server. However, your custom schema files should not be numerically or alphabetically higher than 99user.ldif or the server could experience problems.

The 99user.ldif file contains attributes with the an X-ORIGIN of 'user defined'. If you create a schema file called 99zzz.ldif, the next time you update the schema using LDAP or the Directory Server Console, all of the attributes with an X-ORIGIN value of 'user defined'will be written to 99zzz.ldif. The directory writes them to 99zzz.ldif because the directory uses the highest sequenced file (numerically, then alphabetically) for its internal schema management. The result is two LDIF files that contain duplicate information and some information in the 99zzz.ldif file might be erased.

When naming custom schema files, name them as follows:

[00-99]yourname.ldif

The directory loads these schema files in numerical order, followed by alphabetical order. For this reason, you should use a number scheme that is higher than any directory standard schema defined. For example, example.com Corporation creates a new schema file named 60examplecorp.ldif. If you name your schema file something lower than the standard schema files, the server may encounter errors when loading the schema. In addition, all standard attributes and object classes will be loaded only after your custom schema elements have been loaded.

You should not use 'user defined' in the X-ORIGIN field of your custom schema files as 'user defined' is used internally by the directory when schema is added over LDAP. Use something more descriptive, such as 'example.com Corporation defined'.

After you have created custom schema files, you can either:

If you do not copy these custom schema files to all of your servers, the schema information will only be replicated to the consumer when changes are made to the schema on the supplier using LDAP or the Directory Server Console.

When the schema definitions are then replicated to a consumer server where they do not already exist, they will be stored in the 99user.ldif file. The directory does not track where schema definitions are stored. Storing schema elements in the 99user.ldif file of consumers does not create a problem as long as you maintain your schema on the master server only.

If you copy your custom schema files to each server, when changes are made to the schema files, they must be copied again to each server. If you do not copy them again, it is possible the changes will be replicated and stored in the 99user.ldif file on the consumer. Having the changes in the 99user.ldif file may make schema management difficult, as some attributes will appear in two separate schema files on a consumer, once in the original custom schema file you copied from the supplier and again in the 99user.ldif file after replication.

For more information about replicating schema, see "Schema Replication".

Custom Schema Best Practices

Consider the following points when creating custom schema elements:

Maintaining Consistent Schema


A consistent schema within Directory Server aids LDAP client applications in locating directory entries. If you use an inconsistent schema, then it becomes very difficult to locate information in your directory tree efficiently.

Inconsistent schema use different attributes or formats to store the same information. You can maintain schema consistency in the following ways:

The following sections describe in detail how to maintain consistency within your schema.

Schema Checking

Schema checking ensures that all new or modified directory entries conform to the schema rules. When the rules are violated, the directory rejects the requested change.


Note  

Schema checking checks only that the proper attributes are present. It does not verify whether attribute values are in the correct syntax for the attribute.




By default, the directory enables schema checking. We do not recommend turning it off. For information on turning schema checking on and off, see the Netscape Directory Server Administrator's Guide.

With schema checking on, you must be attentive to required and allowed attributes as defined by the object classes. Object class definitions usually contain at least one required attribute, and one or more optional attributes. Optional attributes are attributes that you are allowed, but not required, to add to the directory entry. If you attempt to add an attribute to an entry that is neither required nor allowed according to the entry's object class definition, then Directory Server returns an object class violation message.

For example, if you define an entry to use the organizationalPerson object class, then the commonName (cn) and surname (sn) attributes are required for the entry (you must specify values for these attributes when you create the entry). In addition, there is a fairly long list of attributes that you can optionally use on the entry. This list includes such descriptive attributes as telephoneNumber, uid, streetAddress, and userPassword.

Selecting Consistent Data Formats

LDAP schema allow you to place any data that you want on any attribute value. However, it is important to store data consistently in your directory tree by selecting a format appropriate for your LDAP client applications and directory users.

With the LDAP protocol and Directory Server, you must represent data in the data formats specified in RFC 2252.

In addition, the correct LDAP format for telephone numbers is defined in the following ITU-T Recommendations documents:

For example, a US phone number would be formatted as follows:

+1 555 222 1717

The postalAddress attribute expects an attribute value in the form of a multiline string that uses dollar signs ($) as line delimiters. A properly formatted directory entry appears as follows:

postalAddress: 1206 Directory Drive$Pleasant View, MN$34200

Maintaining Consistency in Replicated Schema

When you make changes to your directory schema, the change is recorded in the change log. During replication, the change log is scanned for changes, and any changes made are replicated. Maintaining consistency in replicated schema allows replication to continue smoothly. Consider the following points for maintaining consistent schema in a replicated environment:

Other Schema Resources


Refer to the following links for more information about standard LDAPv3 schema:



Previous      Contents      Index      DocHome      Next     

© 2001 Sun Microsystems, Inc. Portions copyright 1999, 2002-2003 Netscape Communications Corporation. All rights reserved.
Read the Full Copyright and Thrid-Party Acknowledgments.


Last Updated October 30, 2003