Red Hat DIRECTORY SERVER 7.1 - PLUG-IN PROGRAMMERS Manual page 112

Table of Contents

Advertisement

Writing a Pre-Operation Bind Plug-in
Code Example 8-1
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
/* Gets parameters available when processing an LDAP bind
if ( slapi_pblock_get( pb, SLAPI_BIND_TARGET, &dn ) != 0 ||
) != 0 ) {
}
/* Check the authentication method */
switch( method ) {
case LDAP_AUTH_SIMPLE:
SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
attribute
) {
110
Red Hat Directory Server Plug-in Programmer's Guide • May 2005
Sample Pre-Operation Bind Function (Continued)
"Pre-operation bind function called.\n" );
operation. */
slapi_pblock_get( pb, SLAPI_BIND_METHOD, &method ) != 0 ||
slapi_pblock_get( pb, SLAPI_BIND_CREDENTIALS, &credentials
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
"Could not get parameters for bind operation\n" );
slapi_send_ldap_result( pb, LDAP_OPERATIONS_ERROR,
NULL, NULL, 0, NULL );
return( 1 );
/* First, get the entry specified by the DN. */
searchpb = slapi_search_internal( dn, LDAP_SCOPE_BASE,
"(objectclass=*)", NULL, NULL, 0 );
if ( searchpb != NULL ) {
slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_RESULT, &rc );
if ( rc == LDAP_SUCCESS ) {
slapi_pblock_get( searchpb,
&entries );
if ( entries != NULL && entries[0] != NULL ) {
e = entries[0];
} else {
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
"Could not find entry for %s\n", dn );
rc = LDAP_NO_SUCH_OBJECT;
break;
}
} else {
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
"Could not find entry for %s (error %d)\n", dn, rc );
break;
}
} else {
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
"Could not search for entry\n" );
rc = LDAP_OPERATIONS_ERROR;
break;;
}
/* Next, check the credentials against the userpassword
of that entry. */
if ( e != NULL ) {
if ( slapi_entry_attr_find( e, "userpassword", &attr ) != 0
slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind",
"Entry has no userpassword attribute\n" );
rc = LDAP_INAPPROPRIATE_AUTH;

Advertisement

Table of Contents
loading

This manual is also suitable for:

Directory server 7.1

Table of Contents