### Step 4: Create Descriptor Lists for Attributes

The following code fragments show how the attribute lists are created for the attributes to be added to the directory.

First, initialize the public object object_class to contain the representation of the classes in the DIT that are common to both Organizational-Person entries, Top, Person, and Organizational-Person:

/* Build up an array of object identifiers for the */

/* attributes to be added to the directory. */

static OM_descriptor object_class[] = {

OM_OID_DESC(OM_CLASS, DS_C_ATTRIBUTE),

OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_OBJECT_CLASS),

OM_OID_DESC(DS_ATTRIBUTE_VALUES, DS_O_TOP),

OM_OID_DESC(DS_ATTRIBUTE_VALUES, DS_O_PERSON),

OM_OID_DESC(DS_ATTRIBUTE_VALUES, DS_O_ORG_PERSON),

OM_NULL_DESCRIPTOR

};

Next, initialize the public objects that represent the attributes to be added: surname and telephone for the distinguished name of Brendan, and surname2 and password for the distinguished name of Sinead:

static OM_descriptor telephone[] = {

OM_OID_DESC(OM_CLASS, DS_C_ATTRIBUTE),

OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_PHONE_NBR),

{DS_ATTRIBUTE_VALUES, OM_S_PRINTABLE_STRING,

OM_STRING("+49 89 636 0")},

OM_NULL_DESCRIPTOR

};

static OM_descriptor surname[] = {

OM_OID_DESC(OM_CLASS, DS_C_AVA),

OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_SURNAME),

{DS_ATTRIBUTE_VALUES, OM_S_TELETEX_STRING,

OM_STRING("Moloney")},

OM_NULL_DESCRIPTOR

};

static OM_descriptor surname2[] = {

OM_OID_DESC(OM_CLASS, DS_C_AVA),

OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_SURNAME),

{DS_ATTRIBUTE_VALUES, OM_S_TELETEX_STRING,

OM_STRING("Murphy")},

OM_NULL_DESCRIPTOR

};

static OM_descriptor password[] = {

OM_OID_DESC(OM_CLASS, DS_C_AVA),

OM_OID_DESC(DS_ATTRIBUTE_TYPE, DS_A_USER_PASSWORD),

{DS_ATTRIBUTE_VALUES, OM_S_OCTET_STRING,

OM_STRING("secret")},

OM_NULL_DESCRIPTOR

};

Finally, initialize the public objects that represent the list of attributes to be added to the directory: attr_list1 for the distinguished name Brendan, and attr_list2 for the distinguished name Sinead:

static OM_descriptor attr_list1[] = {

OM_OID_DESC(OM_CLASS, DS_C_ATTRIBUTE_LIST),

{DS_ATTRIBUTES, OM_S_OBJECT, {0, object_class} },

{DS_ATTRIBUTES, OM_S_OBJECT, {0, surname} },

{DS_ATTRIBUTES, OM_S_OBJECT, {0, telephone} },

OM_NULL_DESCRIPTOR

};

static OM_descriptor attr_list2[] = {

OM_OID_DESC(OM_CLASS, DS_C_ATTRIBUTE_LIST),

{DS_ATTRIBUTES, OM_S_OBJECT, {0, object_class} },

{DS_ATTRIBUTES, OM_S_OBJECT, {0, surname2} },

{DS_ATTRIBUTES, OM_S_OBJECT, {0, password} },

OM_NULL_DESCRIPTOR

};

The attr_list1 variable contains the public objects surname and telephone, the C representations of the attributes of the distinguished name /C=ie/O=sni/OU=ap/CN=Brendan that are added to the directory. The attr_list2 variable contains the public objects first surname2 and password, which are the C representations of the attributes of the distinguished name /C=ie/O=sni/OU=ap/CN=Sinead.

###