version 1.99.2.6, 2005/08/10 21:57:17
|
version 1.99.2.7, 2005/08/25 05:01:16
|
Line 1
|
Line 1
|
/* result.c - wait for an ldap result */ |
/* result.c - wait for an ldap result */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.111 2005/08/09 22:54:38 hallvard Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/libldap/result.c,v 1.113 2005/08/22 07:41:36 ando Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2005 The OpenLDAP Foundation. |
* Copyright 1998-2005 The OpenLDAP Foundation. |
Line 407 try_read1msg(
|
Line 407 try_read1msg(
|
* v3ref = flag for V3 referral / search reference |
* v3ref = flag for V3 referral / search reference |
* 0 = not a ref, 1 = sucessfully chased ref, -1 = pass ref to application |
* 0 = not a ref, 1 = sucessfully chased ref, -1 = pass ref to application |
*/ |
*/ |
int v3ref; |
enum { |
|
V3REF_NOREF = 0, |
|
V3REF_SUCCESS = 1, |
|
V3REF_TOAPP = -1 |
|
} v3ref; |
|
|
assert( ld != NULL ); |
assert( ld != NULL ); |
assert( lcp != NULL ); |
assert( lcp != NULL ); |
Line 519 nextresp2:
|
Line 523 nextresp2:
|
* This code figures out if we are going to chase a |
* This code figures out if we are going to chase a |
* referral / search reference, or pass it back to the application |
* referral / search reference, or pass it back to the application |
*/ |
*/ |
v3ref = 0; /* Assume not a V3 search reference or referral */ |
v3ref = V3REF_NOREF; /* Assume not a V3 search reference/referral */ |
if( (tag != LDAP_RES_SEARCH_ENTRY) && (ld->ld_version > LDAP_VERSION2) ) { |
if( (tag != LDAP_RES_SEARCH_ENTRY) && (ld->ld_version > LDAP_VERSION2) ) { |
BerElement tmpber = *ber; /* struct copy */ |
BerElement tmpber = *ber; /* struct copy */ |
char **refs = NULL; |
char **refs = NULL; |
|
|
if( tag == LDAP_RES_SEARCH_REFERENCE) { |
if( tag == LDAP_RES_SEARCH_REFERENCE ) { |
/* This is a V3 search reference */ |
/* This is a V3 search reference */ |
/* Assume we do not chase the reference, but pass it to application */ |
/* Assume we do not chase the reference, |
v3ref = -1; |
* but pass it to application */ |
|
v3ref = V3REF_TOAPP; |
if( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) || |
if( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) || |
(lr->lr_parent != NULL) ) |
(lr->lr_parent != NULL) ) |
{ |
{ |
Line 535 nextresp2:
|
Line 540 nextresp2:
|
if ( ber_scanf( &tmpber, "{v}", &refs ) == LBER_ERROR ) { |
if ( ber_scanf( &tmpber, "{v}", &refs ) == LBER_ERROR ) { |
rc = LDAP_DECODING_ERROR; |
rc = LDAP_DECODING_ERROR; |
} else { |
} else { |
/* Note: refs arrary is freed by ldap_chase_v3referrals */ |
/* Note: refs array is freed by ldap_chase_v3referrals */ |
refer_cnt = ldap_chase_v3referrals( ld, lr, refs, |
refer_cnt = ldap_chase_v3referrals( ld, lr, refs, |
1, &lr->lr_res_error, &hadref ); |
1, &lr->lr_res_error, &hadref ); |
if ( refer_cnt > 0 ) { /* sucessfully chased reference */ |
if ( refer_cnt > 0 ) { |
|
/* sucessfully chased reference */ |
/* If haven't got end search, set chasing referrals */ |
/* If haven't got end search, set chasing referrals */ |
if( lr->lr_status != LDAP_REQST_COMPLETED) { |
if( lr->lr_status != LDAP_REQST_COMPLETED) { |
lr->lr_status = LDAP_REQST_CHASINGREFS; |
lr->lr_status = LDAP_REQST_CHASINGREFS; |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: search ref chased, mark request chasing refs, id = %d\n", |
"read1msg: search ref chased, " |
lr->lr_msgid, 0, 0); |
"mark request chasing refs, " |
|
"id = %d\n", |
|
lr->lr_msgid, 0, 0); |
} |
} |
v3ref = 1; /* We sucessfully chased the reference */ |
|
|
/* We sucessfully chased the reference */ |
|
v3ref = V3REF_SUCCESS; |
} |
} |
} |
} |
} |
} |
Line 572 nextresp2:
|
Line 582 nextresp2:
|
/* Check if V3 referral */ |
/* Check if V3 referral */ |
if ( ber_peek_tag( &tmpber, &len ) == LDAP_TAG_REFERRAL ) { |
if ( ber_peek_tag( &tmpber, &len ) == LDAP_TAG_REFERRAL ) { |
/* We have a V3 referral, assume we cannot chase it */ |
/* We have a V3 referral, assume we cannot chase it */ |
v3ref = -1; |
v3ref = V3REF_TOAPP; |
if( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) |
if( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) |
|| (lr->lr_parent != NULL) ) |
|| (lr->lr_parent != NULL) ) |
{ |
{ |
v3ref = -1; /* Assume referral not chased and return it to app */ |
/* Assume referral not chased and return it to app */ |
|
v3ref = V3REF_TOAPP; |
|
|
/* Get the referral list */ |
/* Get the referral list */ |
if( ber_scanf( &tmpber, "{v}", &refs) == LBER_ERROR) { |
if( ber_scanf( &tmpber, "{v}", &refs) == LBER_ERROR) { |
rc = LDAP_DECODING_ERROR; |
rc = LDAP_DECODING_ERROR; |
Line 595 nextresp2:
|
Line 607 nextresp2:
|
"read1msg: referral chased, mark request completed, id = %d\n", |
"read1msg: referral chased, mark request completed, id = %d\n", |
lr->lr_msgid, 0, 0); |
lr->lr_msgid, 0, 0); |
if( refer_cnt > 0) { |
if( refer_cnt > 0) { |
v3ref = 1; /* Referral successfully chased */ |
/* Referral successfully chased */ |
|
v3ref = V3REF_SUCCESS; |
} |
} |
} |
} |
} |
} |
Line 617 nextresp2:
|
Line 630 nextresp2:
|
* go through the following code. This code also chases V2 referrals |
* go through the following code. This code also chases V2 referrals |
* and checks if all referrals have been chased. |
* and checks if all referrals have been chased. |
*/ |
*/ |
if ( (tag != LDAP_RES_SEARCH_ENTRY) && (v3ref > -1) && |
if ( (tag != LDAP_RES_SEARCH_ENTRY) && (v3ref != V3REF_TOAPP) && |
(tag != LDAP_RES_INTERMEDIATE )) |
(tag != LDAP_RES_INTERMEDIATE )) |
{ |
{ |
/* For a v3 search referral/reference, only come here if already chased it */ |
/* For a v3 search referral/reference, only come here if already chased it */ |
Line 628 nextresp2:
|
Line 641 nextresp2:
|
char *lr_res_error = NULL; |
char *lr_res_error = NULL; |
|
|
tmpber = *ber; /* struct copy */ |
tmpber = *ber; /* struct copy */ |
if ( v3ref == 1 ) { |
if ( v3ref == V3REF_SUCCESS ) { |
/* V3 search reference or V3 referral |
/* V3 search reference or V3 referral |
* sucessfully chased. If this message |
* sucessfully chased. If this message |
* is a search result, then it has no more |
* is a search result, then it has no more |
Line 647 nextresp2:
|
Line 660 nextresp2:
|
} else { |
} else { |
lr->lr_res_error = lr_res_error; |
lr->lr_res_error = lr_res_error; |
} |
} |
|
lr_res_error = NULL; |
} |
} |
|
|
if ( lderr != LDAP_SUCCESS ) { |
switch ( lderr ) { |
|
case LDAP_SUCCESS: |
|
case LDAP_COMPARE_TRUE: |
|
case LDAP_COMPARE_FALSE: |
|
break; |
|
|
|
default: |
|
if ( lr->lr_res_error == NULL |
|
|| lr->lr_res_error[ 0 ] == '\0' ) |
|
{ |
|
break; |
|
} |
|
|
/* referrals are in error string */ |
/* referrals are in error string */ |
refer_cnt = ldap_chase_referrals( ld, lr, |
refer_cnt = ldap_chase_referrals( ld, lr, |
&lr->lr_res_error, -1, &hadref ); |
&lr->lr_res_error, -1, &hadref ); |
lr->lr_status = LDAP_REQST_COMPLETED; |
lr->lr_status = LDAP_REQST_COMPLETED; |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"read1msg: V2 referral chased, mark request completed, id = %d\n", lr->lr_msgid, 0, 0); |
"read1msg: V2 referral chased, " |
|
"mark request completed, id = %d\n", |
|
lr->lr_msgid, 0, 0 ); |
|
break; |
} |
} |
|
|
/* save errno, message, and matched string */ |
/* save errno, message, and matched string */ |