PreviousNext

Building a Name Object

Complete definitions for all the object classes required as input for XDS functions can be found in XDS/CDS Object Recipes. Among them is the class for distinguished name objects, called DS_C_DS_DN. There you will learn that this class of object has two attributes: its class attribute, which identifies it as a DS_C_DS_DN object, and a second attribute, which occurs multiple times in the object. Each instance of this attribute contains as its value one piece of the full name; for example, the directory name hosts.

The DS_C_DS_DN attribute that holds the entry name piece, or relative distinguished name (RDN), is defined by the class rules to hold, not a string, but another object of the RDN class (DS_C_DS_RDN).

Thus, a static declaration of the descriptor array representing the DS_C_DS_DN object would look like the following:

static OM_descriptor Full_Entry_Name_Object[] = {

OM_OID_DESC(OM_CLASS, DS_C_DS_DN),

/* ^^^^^^^^^^^ */

/* Macro to put an "OID string" in a descriptor's */

/* type field and fill its other */

/* fields with appropriate values. */


{DS_RDNS, OM_S_OBJECT, {0, Country_RDN}},

/* ^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ */

/* type syntax value */

/* */

/* (the "value" union is in fact here a */

/* structure; the 0 fills a pad field in */

/* that structure.) */

{DS_RDNS, OM_S_OBJECT, {0, Organization_RDN}},

{DS_RDNS, OM_S_OBJECT, {0, Org_Unit_RDN}},

{DS_RDNS, OM_S_OBJECT, {0, Hosts_Dir_RDN}},

{DS_RDNS, OM_S_OBJECT, {0, Tamburlaine_Dir_RDN}},

{DS_RDNS, OM_S_OBJECT, {0, Self_Entry_RDN}},


OM_NULL_DESCRIPTOR

/* ^^^^^^^^^^^^^^^^^^ */

/* Macro to fill a descriptor with proper */

/* NULL values. */



};

The use of the OM_OID_DESC and OM_NULL_DESCRIPTOR macros slightly obscures the layout of this declaration. However, each line contains code to initialize exactly one OM_descriptor object; the array consists of eight objects.

The names (such as Country_RDN) in the descriptors' value fields refer to the other descriptor arrays, which separately represent the relative name objects. (The order of the C declaration in the source file is opposite to the order described here.) Since DS_C_DS_RDN objects are now called for, the next step is to look at what attributes that class requires.

The definition for DS_C_DS_RDN can be found in The DS_C_DS_RDN Object. This class object is defined, like DS_C_DS_DN, to have only one attribute (with the exception of the OM_Object attribute, which is mandatory for all objects). The one attribute, DS_AVAS, holds the value of one relative name. The syntax of this value is OM_S_OBJECT, meaning that DS_AVAS's value is a pointer to yet another object descriptor array:

static OM_descriptor Country_RDN[] = {

OM_OID_DESC(OM_CLASS, DS_C_DS_RDN),

{DS_AVAS, OM_S_OBJECT, {0, Country_Value}},

OM_NULL_DESCRIPTOR

};

Note that there should also be five other similar declarations, one for each of the other DS_C_DS_RDN objects held in the DS_C_DS_DN.

The declarations have the same meanings as they did in the previous example. Country_Value is the name of the descriptor array that represents the object of class DS_C_AVA, which we are now about to look up.

The rules for the DS_C_AVA class can be found in this topic just after DS_C_DS_RDN. They tell us that DS_C_AVA objects have two attributes aside from the omnipresent OM_Object; namely:

· DS_ATTRIBUTE_VALUES

This attribute holds the object's value.

· DS_ATTRIBUTE_TYPE

This attribute gives the meaning of the object's value.

In this instance, the meaning of the string US is that it is a country name. There is a particular directory service attribute value for this; it is identified by an OID that is associated with the label DS_A_COUNTRY_NAME (the OIDs held in objects are represented in string form). Accordingly, we make that OID the value of DS_ATTRIBUTE_TYPE, and we make the name string itself the value of DS_ATTRIBUTE_VALUES:

static OM_descriptor Country_Value[] = {

OM_OID_DESC(OM_CLASS, DS_C_AVA),


OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_COUNTRY_NAME),


{DS_ATTRIBUTE_VALUES, OM_S_PRINTABLE_STRING, OM_STRING("US")},

/* ^^^^^^^^^^^^^^^ */

/* Macro to properly */

/* fill the "value" union with the NULL-terminated string. */



OM_NULL_DESCRIPTOR

};

There are also five other DS_C_AVA declarations, one for each of the five other separate name piece objects referred to in the DS_C_DS_RDN superobjects.