Using SASL with an LDAP Client
•
ld
containing information about the connection to the LDAP server.
•
res
want to parse.
•
servercredp
credentials returned by the server. These are the credentials that you set as the
value of the
plug-in function.
•
freeit
freed after the error code is extracted. If 0, the result is not freed. If non-zero, the result is
freed.
The following example is an LDAP client that authenticates using the SASL
method named
Code Example 8-3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ldap.h>
int
main( int argc, char **argv )
{
LDAP
LDAPMod
LDAPMod
LDAPMod
char
char
time_t
char
struct berval cred;
struct berval *servcred;
int version;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( "localhost", 389 )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* Set the LDAP protocol version supported by the client
to 3. (By default, this is set to 2. Extended operations
are part of version 3 of the LDAP protocol.) */
version = LDAP_VERSION3;
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
/* authenticate */
cred.bv_val = "magic";
cred.bv_len = sizeof( "magic" ) - 1;
108
Netscape Directory Server Plug-In Programmer's Guide • May 2002
is the connection handle, which is a pointer to the LDAP structure
is a pointer to the
LDAPMessage
is a pointer to a pointer to the
SLAPI_BIND_RET_SASLCREDS
s
pecifies whether or not the result (the LDAPMessage structure) should be
babsmechanism
LDAP Client Authenticating Using SASL Method
*ld;
mod0;
mod1;
*mods[ 3 ];
*vals0[ 2 ];
*vals1[ 2 ];
now;
buf[ 128 ];
structure containing the results that you
berval
parameter in your pre-operation bind
.
structure containing any
Need help?
Do you have a question about the NETSCAPE DIRECTORY SERVER 6.02 - PLUG-IN and is the answer not in the manual?
Questions and answers