version 1.41.2.8, 2004/01/21 08:03:23
|
version 1.42, 2002/04/01 20:28:02
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/libraries/libldap/sasl.c,v 1.41.2.7 2003/05/22 22:22:41 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/sasl.c,v 1.41 2002/01/04 20:17:39 kurt Exp $ */ |
/* |
/* |
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. |
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
*/ |
*/ |
|
|
Line 62 ldap_sasl_bind(
|
Line 62 ldap_sasl_bind(
|
int rc; |
int rc; |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, ENTRY, "ldap_sasl_bind\n", 0, 0, 0 ); |
LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_sasl_bind\n" )); |
#else |
#else |
Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); |
#endif |
#endif |
Line 75 ldap_sasl_bind(
|
Line 75 ldap_sasl_bind(
|
rc = ldap_int_client_controls( ld, cctrls ); |
rc = ldap_int_client_controls( ld, cctrls ); |
if( rc != LDAP_SUCCESS ) return rc; |
if( rc != LDAP_SUCCESS ) return rc; |
|
|
|
if( msgidp == NULL ) { |
|
ld->ld_errno = LDAP_PARAM_ERROR; |
|
return ld->ld_errno; |
|
} |
|
|
if( mechanism == LDAP_SASL_SIMPLE ) { |
if( mechanism == LDAP_SASL_SIMPLE ) { |
if( dn == NULL && cred != NULL && cred->bv_len ) { |
if( dn == NULL && cred != NULL ) { |
/* use default binddn */ |
/* use default binddn */ |
dn = ld->ld_defbinddn; |
dn = ld->ld_defbinddn; |
} |
} |
Line 105 ldap_sasl_bind(
|
Line 110 ldap_sasl_bind(
|
ld->ld_version, dn, LDAP_AUTH_SIMPLE, |
ld->ld_version, dn, LDAP_AUTH_SIMPLE, |
cred ); |
cred ); |
|
|
} else if ( cred == NULL || cred->bv_val == NULL ) { |
} else if ( cred == NULL || !cred->bv_len ) { |
/* SASL bind w/o creditials */ |
/* SASL bind w/o creditials */ |
rc = ber_printf( ber, "{it{ist{sN}N}" /*}*/, |
rc = ber_printf( ber, "{it{ist{sN}N}" /*}*/, |
++ld->ld_msgid, LDAP_REQ_BIND, |
++ld->ld_msgid, LDAP_REQ_BIND, |
Line 138 ldap_sasl_bind(
|
Line 143 ldap_sasl_bind(
|
return ld->ld_errno; |
return ld->ld_errno; |
} |
} |
|
|
|
#ifndef LDAP_NOCACHE |
|
if ( ld->ld_cache != NULL ) { |
|
ldap_flush_cache( ld ); |
|
} |
|
#endif /* !LDAP_NOCACHE */ |
|
|
/* send the message */ |
/* send the message */ |
*msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ); |
*msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ); |
Line 164 ldap_sasl_bind_s(
|
Line 174 ldap_sasl_bind_s(
|
struct berval *scredp = NULL; |
struct berval *scredp = NULL; |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, ENTRY, "ldap_sasl_bind_s\n", 0, 0, 0 ); |
LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_sasl_bind_s\n" )); |
#else |
#else |
Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind_s\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind_s\n", 0, 0, 0 ); |
#endif |
#endif |
Line 250 ldap_parse_sasl_bind_result(
|
Line 260 ldap_parse_sasl_bind_result(
|
BerElement *ber; |
BerElement *ber; |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, ENTRY, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); |
LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_parse_sasl_bind_result\n" )); |
#else |
#else |
Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); |
#endif |
#endif |
Line 259 ldap_parse_sasl_bind_result(
|
Line 269 ldap_parse_sasl_bind_result(
|
assert( LDAP_VALID( ld ) ); |
assert( LDAP_VALID( ld ) ); |
assert( res != NULL ); |
assert( res != NULL ); |
|
|
|
if ( ld == NULL || res == NULL ) { |
|
return LDAP_PARAM_ERROR; |
|
} |
|
|
if( servercredp != NULL ) { |
if( servercredp != NULL ) { |
if( ld->ld_version < LDAP_VERSION2 ) { |
if( ld->ld_version < LDAP_VERSION2 ) { |
return LDAP_NOT_SUPPORTED; |
return LDAP_NOT_SUPPORTED; |
Line 363 ldap_pvt_sasl_getmechs ( LDAP *ld, char
|
Line 377 ldap_pvt_sasl_getmechs ( LDAP *ld, char
|
int rc; |
int rc; |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, ENTRY, "ldap_pvt_sasl_getmech\n", 0, 0, 0 ); |
LDAP_LOG (( "sasl", LDAP_LEVEL_ENTRY, "ldap_pvt_sasl_getmech\n" )); |
#else |
#else |
Debug( LDAP_DEBUG_TRACE, "ldap_pvt_sasl_getmech\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_TRACE, "ldap_pvt_sasl_getmech\n", 0, 0, 0 ); |
#endif |
#endif |
Line 427 ldap_sasl_interactive_bind_s(
|
Line 441 ldap_sasl_interactive_bind_s(
|
void *defaults ) |
void *defaults ) |
{ |
{ |
int rc; |
int rc; |
char *smechs = NULL; |
|
|
|
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) |
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) |
ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); |
ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); |
Line 442 ldap_sasl_interactive_bind_s(
|
Line 455 ldap_sasl_interactive_bind_s(
|
return rc < 0 ? rc : 0; |
return rc < 0 ? rc : 0; |
} else |
} else |
#endif |
#endif |
|
|
#ifdef HAVE_CYRUS_SASL |
|
if( mechs == NULL || *mechs == '\0' ) { |
if( mechs == NULL || *mechs == '\0' ) { |
mechs = ld->ld_options.ldo_def_sasl_mech; |
char *smechs; |
} |
|
#endif |
|
|
|
if( mechs == NULL || *mechs == '\0' ) { |
|
rc = ldap_pvt_sasl_getmechs( ld, &smechs ); |
rc = ldap_pvt_sasl_getmechs( ld, &smechs ); |
|
|
if( rc != LDAP_SUCCESS ) { |
if( rc != LDAP_SUCCESS ) { |
Line 457 ldap_sasl_interactive_bind_s(
|
Line 465 ldap_sasl_interactive_bind_s(
|
} |
} |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, DETAIL1, |
LDAP_LOG (( "sasl", LDAP_LEVEL_DETAIL1, |
"ldap_interactive_sasl_bind_s: server supports: %s\n", |
"ldap_interactive_sasl_bind_s: server supports: %s\n", smechs )); |
smechs, 0, 0 ); |
|
#else |
#else |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_interactive_sasl_bind_s: server supports: %s\n", |
"ldap_interactive_sasl_bind_s: server supports: %s\n", |
Line 470 ldap_sasl_interactive_bind_s(
|
Line 477 ldap_sasl_interactive_bind_s(
|
|
|
} else { |
} else { |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG ( TRANSPORT, DETAIL1, |
LDAP_LOG (( "sasl", LDAP_LEVEL_DETAIL1, |
"ldap_interactive_sasl_bind_s: user selected: %s\n", mechs, 0, 0 ); |
"ldap_interactive_sasl_bind_s: user selected: %s\n", mechs )); |
#else |
#else |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"ldap_interactive_sasl_bind_s: user selected: %s\n", |
"ldap_interactive_sasl_bind_s: user selected: %s\n", |
Line 487 done:
|
Line 494 done:
|
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) |
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) |
ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); |
ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); |
#endif |
#endif |
if ( smechs ) LDAP_FREE( smechs ); |
|
|
|
return rc; |
return rc; |
} |
} |