HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
5 Front end API functions
The HP-UX Directory Server (Directory Server) provides some general-purpose, front end API
functions that allow you to work with the entries in the Directory Server. This chapter explains
how to use the front end API functions to accomplish various tasks; you can call these functions
in your plug-in to interact with the client (for example, to send results or result codes), log
messages, and work with entries, attributes, and filters. While all the functions described here
must be used in conjunction with other API functions, understanding how these functions work
will help you understand how to program other plug-in API functions.
The front end functions are declared in the slapi-plugin.h header file.
5.1 Logging messages
To write an error message to the error log, call the “slapi_log_error()” function. For example, the
following function call writes a message in the error log:
slapi_log_error( SLAPI_LOG_PLUGIN, "searchdn_preop_search", "*** PREOPER\
ATION SEARCH PLUGIN ***\n");
This call will create the following message in the error log:
[01/Oct/2009:02:24:18 -0700] searchdn_preop_search \ - *** PREOPERATION
SEARCH PLUGIN ***
Make sure that the Directory Server is configured to log messages that have the severity that you
specify (for example, SLAPI_LOG_PLUGIN). For more information, refer to “Setting the log level
of the server. The “slapi_log_error()” function allows additional parameters to be added to the
function and to format the output, similar to the standard printf() function. This provides a
way to add custom parameters and data to the log output.
5.2 Adding notes to access log entries
When the back end database processes a search operation, it attempts to use indexes to narrow
down the list of candidates matching the search criteria. If the back end is unable to use indexes,
it appends the following string to the access log entry for the search: notes="U"
This note indicates that an unindexed search was performed.
If you are writing your own back end database search function, you can append this note to
access log entries by setting the SLAPI_OPERATION_NOTES parameter to the flag
SLAPI_OP_NOTE_UNINDEXED. This parameter identifies any notes that need to be appended
to access log entries. Currently, SLAPI_OP_NOTE_UNINDEXED is the only value that you can
set for this parameter. In future releases, additional flags will be defined. You will be able to use
bitwise OR combinations of flags to specify different combinations of notes.
The server appends these notes and writes out the access log entries whenever sending a result
or search entry back to the client.
5.3 Sending data to the client
Sometimes you might need to communicate various information directly to the client. This could
occur in the following situations:
If you need to send a result code to the client (for example, to report an error or a successful
result to an LDAP operation), call the “slapi_send_ldap_result()” function.
If you are fulfilling a search request and need to send matching entries to the client, call the
“slapi_send_ldap_search_entry()” function for each entry.
If you need to refer the LDAP request to a different LDAP server, call the
“slapi_send_ldap_referral()” function.
5.1 Logging messages 49