HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
You can use the following functions to convert between the LDIF string representation of an
entry and its Slapi_Entry data type:
To convert an entry from the Slapi_Entry data type to its LDIF string representation, call
the “slapi_entry2str()” and “slapi_entry2str_with_options()” functions.
This function returns the LDIF string representation of the entry, or NULL if an error occurs.
When the string is no longer required, you should free it from memory by calling the
slapi_ch_free_string() function.
To convert an LDIF string representation back to an entry of the data type Slapi_Entry,
call the “slapi_str2entry()” function.
This function returns an entry of the data type Slapi_Entry. If an error occurred during
the conversion process, the function returns NULL instead.
When you are finished working with the entry, you should call the “slapi_entry_free()” function.
Note:
When you call the “slapi_str2entry()” function, it modifies the value of the string argument
passed into the function (not a copy). If you still want to use the string representation of the
entry, make a copy of the string before calling this function.
5.5.3 Miscellaneous operations
5.5.3.1 Getting and setting the DN of an entry
You can call the following two front end routines to get and set the DN for an entry:
To get the DN for an entry, call the “slapi_entry_get_dn()” function.
To set the DN for an entry, call the “slapi_entry_set_dn()” function.
5.5.3.2 Verifying compliance with the schema
Before you add or modify an entry in the database, you may want to verify that the new or
changed entry still complies with the database schema.
To verify that an entry complies with the schema, call the “slapi_entry_schema_check()” function.
5.5.3.3 Getting the attributes and values of an entry
You can use either of the following methods to obtain the attributes and values of an entry:
Iterate through the attributes of the entry, testing each one to determine if it is the required
attribute.
Use the “slapi_entry_attr_find()” function to determine if an entry has a specific attribute.
After you have found the required attribute, use the slapi_attr_value_find() function to return
the value of that attribute.
5.5.3.3.1 Iterating through the attributes in an entry
To iterate through the attributes associated with an entry, call the “slapi_entry_first_attr()”
function to get the first attribute of the entry. This function returns a pointer to the first attribute
in the entry. You can use the pointer to the attribute to determine if it is the attribute that you
want.
To retrieve the subsequent parameters in the entry, call “slapi_entry_next_attr()”, and pass it the
pointer to the current parameter in the cookie parameter of the function. The
slapi_entry_next_attr() function returns a pointer to the current parameter in the same
fashion as the slapi_entry_first_attr() function.
After you have found the required attribute, you can retrieve its value using
slapi_attr_value_find().
52 Front end API functions