Using SASL with an LDAP Client
•
ld
containing information about the connection to the LDAP server.
•
res
want to parse.
•
servercredp
any credentials returned by the server. These are the credentials that you set
as the value of the
bind plug-in function.
•
freeit
should be freed after the error code is extracted. 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;
118
Netscape Directory Server Plug-in Programmer's Guide • October 2004
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
specifies whether or not the result (the
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
LDAPMessage
.
structure containing
structure)
, the result is not freed. If
0
Need help?
Do you have a question about the NETSCAPE DIRECTORY SERVER 7.0 - PLUG-IN and is the answer not in the manual?
Questions and answers