HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
int ldif_back_init( Slapi_PBlock *pb )
{ LDIF *db; /* context of the database */
...
/* Allocate space for the database context, which contains information
* about the database and a pointer to the list of entries. */
if ( slapi_pblock_set( pb, SLAPI_PRIVATE, (void *) db ) == -1 )
{
slapi_log_error( SLAPI_LOG_PLUGIN, "ldif_back_init" ,
"Unable to store database information\n" );
}
...
}
This example uses the “slapi_log_error()” function to notify the user if an error occurred.
In this code example, SLAPI_PRIVATE identifies the parameter in the parameter block that
contains private data for use in the database functions. For a complete listing of the parameter
block IDs, see Part V “Parameter block reference”.
2.1.4 Calling front end functions
The types of data that you can get from a parameter block include entries, attributes, distinguished
names, and search filters. If you want to manipulate these data items, you can call the associated
front end API functions provided with the Directory Server. For example, using the front end
API functions, you can:
Write messages to the error log.
Get the attributes of an entry.
Get or set the DN of an entry.
Add or delete the values of an attribute.
Determine the OID of an attribute.
Determine the type of a search filter.
For more information on the front end API, see Chapter 5 “Front end API functions” and
Part IV “Function reference”.
2.1.5 Plug-in return values
If the plug-in function is successful, it should return 0 to the front end. If it is not successful, it
should return a nonzero value, and you should call the front end API function “slapi_log_error()”
to log an error message to describe the problem. Refer to “Logging messages” for more
information.
In some cases, you may need to send an LDAP result back to the client. For example, if you are
writing a preoperation bind function and an error occurs during the processing of the function,
the function should return a nonzero value, log an error message, and send the appropriate
LDAP result code back to the client. For information on the appropriate result code to return to
the client, see the chapter that documents the type of plug-in you are writing.
2.2 Writing plug-in initialization functions
Before the Directory Server can call the plug-in function, the function must be properly initialized.
To do this, you must write an initialization function for the server plug-in. The initialization
function should:
1. Specify the plug-in compatibility version.
2. Register each of the plug-in functions.
3. Return a value to the Directory Server.
2.2 Writing plug-in initialization functions 33