HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
values of the SLAPI_BIND_METHOD parameter (such as LDAP_AUTH_SIMPLE and
LDAP_AUTH_SASL) are integer values defined in the ldap.h header file.
If required, specify the credentials that you want sent back to the client.
If the value of the SLAPI_BIND_METHOD parameter is LDAP_AUTH_SASL and you want to
return a set of credentials to the client, call “slapi_pblock_set()” to set the
SLAPI_BIND_RET_SASLCREDS parameter to the credentials.
Send the result of the authentication process back to the client.
Call “slapi_send_ldap_result()” to send an [LDAP_SUCCESS] return code to the client.
Make sure that your function returns a nonzero value to bypass the default back end bind
function and any postoperation plug-in functions.
8.5.2 Registering the SASL mechanism
If you are using SASL as the authentication method, you need to register the SASL mechanisms
that you plan to use.
In your initialization function (see “Writing plug-in initialization functions”), call the
Chapter 22 “Functions for syntax plug-ins” function and specify the name of the SASL mechanism.
For example:
slapi_register_supported_saslmechanism( "babsmechanism" );
If you do not register your SASL mechanism, the Directory Server will send an
[LDAP_AUTH_METHOD_NOT_SUPPORTED] result code back to the client and will not call
your preoperation bind function.
Note:
Refer to the following source file for an example of a preoperation plug-in function for SASL
authentication with LDAP bind operations:
/opt/dirsrv/devel/example/testsaslbind.c
8.5.3 Example of a preoperation bind plug-in
The following sections document an example of a preoperation bind plug-in that handles
authentication.
Note:
Refer to the following source file for an updated example of a preoperation plug-in function that
handles authentication:
/opt/dirsrv/devel/example/testbind.c
8.5.3.1 Example of a preoperation bind function
The following is an example of a preoperation bind function that authenticates clients and
bypasses the default back end bind function. In this example, the function compares the client's
credentials against the value of the userpassword attribute for the entry.
#include <stdio.h>
#include <string.h>
#include "slapi-plugin.h" /* Preoperation plug-in function */
int test_bind(Slapi_PBlock *pb )
{
char *dn;
int method, rc = LDAP_SUCCESS;
struct berval *credentials;
struct berval **pwvals;
Slapi_PBlock *searchpb = NULL;
Slapi_Entry *e = NULL;
8.5 Writing a preoperation bind plug-in 75