HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
msgidp is a pointer to the message ID for this bind operation. To check the result of this
operation, call the ldap_result() function and the ldap_parse_sasl_bind_result()
function.
servercredp is a pointer to a pointer to the berval structure containing any credentials
returned by the server. These are the credentials that you set as the value of the
SLAPI_BIND_RET_SASLCREDS parameter in your preoperation bind plug-in function.
If you call the ldap_sasl_bind() function, you need to call the ldap_result() function to
get the result of the authentication attempt:
LDAP_API(int) LDAP_CALL ldap_result( LDAP *ld, int msgid,
int all, struct timeval *timeout, LDAPMessage **result );
The parameters are described below:
ld is the connection handle, which is a pointer to the LDAP structure containing information
about the connection to the LDAP server.
msgid is the message ID returned as the last argument of the ldap_sasl_bind() function.
all applies to LDAP search operations. Because this is not an LDAP search operation, you
can pass NULL for this argument.
timeout is the maximum interval to wait for the selection to complete. If timeout is a
NULL pointer, the select blocks indefinitely. To effect a poll, the timeout parameter should
be a non-NULL pointer, pointing to a zero-valued timeval structure.
result is a pointer to an LDAPMessage structure containing the results of the bind
operation. You need to pass this to the ldap_parse_sasl_bind_result() function.
After calling ldap_result(), you need to call the ldap_parse_sasl_bind_result()
function to parse the results and retrieve the LDAP result code and any credentials returned by
the server:
LDAP_API(int) LDAP_CALL ldap_parse_sasl_bind_result( LDAP *ld,
LDAPMessage *res, struct berval **servercredp, int freeit);
The parameters are described below:
ld is the connection handle, which is a pointer to the LDAP structure containing information
about the connection to the LDAP server.
res is a pointer to the LDAPMessage structure containing the results that you want to parse.
servercredp is a pointer to a pointer to the berval structure containing any credentials
returned by the server. These are the credentials that you set as the value of the
SLAPI_BIND_RET_SASLCREDS parameter in your preoperation bind plug-in function.
freeit specifies whether the result (the LDAPMessage structure) should be freed after the
error code is extracted. If set to 0, the result is not freed. If set to a nonzero value, the result
is freed.
The following example is an LDAP client that authenticates using the SASL method named
babsmechanism.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ldap.h>
int main( int argc, char **argv )
{
LDAP *ld;
LDAPMod mod0;
LDAPMod mod1;
LDAPMod *mods[ 3 ];
char *vals0[ 2 ];
char *vals1[ 2 ];
time_t now;
8.6 Using SASL with an LDAP client 79