LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
-LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
-LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char **referralsp, int *hadrefp );
+LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
+ char **errstrp, int sref, int *hadrefp );
+LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
+ char **refs, int sref, char **referralsp, int *hadrefp );
LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
/*
re_encode_request( LDAP *ld,
BerElement *origber,
ber_int_t msgid,
+ int sref,
LDAPURLDesc *srv,
int *type );
/* parse out & follow referrals */
for( i=0; refarray[i] != NULL; i++) {
/* Parse the referral URL */
- if (( rc = ldap_url_parse( refarray[i], &srv)) != LDAP_SUCCESS) {
+ if (( rc = ldap_url_parse_ext( refarray[i], &srv)) != LDAP_SUCCESS) {
ld->ld_errno = rc;
rc = -1;
goto done;
* if two search references come in one behind the other
* for the same server with different contexts.
*/
- Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referrals: queue referral \"%s\"\n",
+ Debug( LDAP_DEBUG_TRACE,
+ "ldap_chase_v3referrals: queue referral \"%s\"\n",
refarray[i], 0, 0);
if( lc->lconn_rebind_queue == NULL ) {
/* Create a referral list */
srv->lud_dn = LDAP_STRDUP( "" );
}
- if (( ber = re_encode_request( ld, origreq->lr_ber,
- ++ld->ld_msgid, srv, &rinfo.ri_request )) == NULL ) {
+ ber = re_encode_request( ld, origreq->lr_ber, ++ld->ld_msgid,
+ sref, srv, &rinfo.ri_request );
+
+ if( ber == NULL ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
rc = -1;
goto done;
}
- Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referral: msgid %d, url \"%s\"\n",
+ Debug( LDAP_DEBUG_TRACE,
+ "ldap_chase_v3referral: msgid %d, url \"%s\"\n",
lr->lr_msgid, refarray[i], 0);
/* Send the new request to the server - may require a bind */
* XXX merging of errors in this routine needs to be improved
*/
int
-ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
+ldap_chase_referrals( LDAP *ld,
+ LDAPRequest *lr,
+ char **errstrp,
+ int sref,
+ int *hadrefp )
{
int rc, count, len;
char *p, *ref, *unfollowed;
*hadrefp = 1;
ber = re_encode_request( ld, origreq->lr_ber,
- ++ld->ld_msgid, srv, &rinfo.ri_request );
+ ++ld->ld_msgid, sref, srv, &rinfo.ri_request );
if( ber == NULL ) {
return -1 ;
re_encode_request( LDAP *ld,
BerElement *origber,
ber_int_t msgid,
+ int sref,
LDAPURLDesc *srv,
int *type )
{
/* use the scope provided in reference */
scope = srv->lud_scope;
- } else if ( scope != LDAP_SCOPE_SUBTREE ) {
+ } else if ( sref && scope != LDAP_SCOPE_SUBTREE ) {
/* use scope implied by previous operation */
/* base -> base */
/* one -> base */
ber_int_t msgid,
int all,
Sockbuf *sb,
- LDAPConn *lc,
+ LDAPConn *lc,
LDAPMessage **result )
{
BerElement *ber;
return( -1 );
}
- Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n",
+ Debug( LDAP_DEBUG_TRACE,
+ "ldap_read: message type %s msgid %ld, original id %ld\n",
ldap_int_msgtype2str( tag ),
(long) lr->lr_msgid, (long) lr->lr_origid );
tmpber = *ber; /* struct copy */
if ( v3ref == 1 ) {
; /* V3 search reference or V3 referral sucessfully chased */
- } else
- if ( ber_scanf( &tmpber, "{iaa}", &lderr,
+ } 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, &hadref );
+ &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);