- /* All results that just return a status, i.e. don't return data
- * go through the following code. This code also chases V2 referrals
- * and checks if all referrals have been chased.
- */
- if ( (tag != LDAP_RES_SEARCH_ENTRY) && (v3ref > -1) &&
- (tag != LDAP_RES_INTERMEDIATE ))
- {
- /* For a v3 search referral/reference, only come here if already chased it */
- if ( ld->ld_version >= LDAP_VERSION2 &&
- ( lr->lr_parent != NULL ||
- LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) )
- {
- tmpber = *ber; /* struct copy */
- if ( v3ref == 1 ) {
- /* V3 search reference or V3 referral
- * sucessfully chased. If this message
- * is a search result, then it has no more
- * outstanding referrals.
- */
- if ( tag == LDAP_RES_SEARCH_RESULT )
- refer_cnt = 0;
- } else if ( ber_scanf( &tmpber, "{iaa}", &lderr,
- &lr->lr_res_matched, &lr->lr_res_error )
- != LBER_ERROR ) {
- if ( lderr != LDAP_SUCCESS ) {
- /* referrals are in error string */
- refer_cnt = ldap_chase_referrals( ld, lr,
- &lr->lr_res_error, -1, &hadref );
- lr->lr_status = LDAP_REQST_COMPLETED;
- Debug( LDAP_DEBUG_TRACE,
- "read1msg: V2 referral chased, mark request completed, id = %d\n", lr->lr_msgid, 0, 0);
- }
+ /* save errno, message, and matched string */
+ if ( !hadref || lr->lr_res_error == NULL ) {
+ lr->lr_res_errno =
+ lderr == LDAP_PARTIAL_RESULTS
+ ? LDAP_SUCCESS : lderr;