2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
15 #include <ac/socket.h>
16 #include <ac/string.h>
23 ldap_first_reference( LDAP *ld, LDAPMessage *chain )
26 assert( chain != NULL );
28 if ( ld == NULL || chain == NULLMSG ) {
32 return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
34 : ldap_next_reference( ld, chain );
38 ldap_next_reference( LDAP *ld, LDAPMessage *ref )
41 assert( ref != NULL );
43 if ( ld == NULL || ref == NULLMSG ) {
52 if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
61 ldap_count_references( LDAP *ld, LDAPMessage *chain )
66 assert( chain != NULL );
72 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
73 if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
86 LDAPControl ***serverctrls,
94 assert( ref != NULL );
96 if( ld == NULL || ref == NULL ||
97 ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
99 return LDAP_PARAM_ERROR;
102 /* make a private copy of BerElement */
103 SAFEMEMCPY(&be, ref->lm_ber, sizeof(be));
105 if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) {
106 rc = LDAP_DECODING_ERROR;
107 goto free_and_return;
110 if ( serverctrls == NULL ) {
112 goto free_and_return;
115 if ( ber_scanf( &be, /*{*/ "}" ) == LBER_ERROR ) {
116 rc = LDAP_DECODING_ERROR;
117 goto free_and_return;
120 rc = ldap_int_get_controls( &be, serverctrls );
124 if( referralsp != NULL ) {
125 /* provide references regradless of return code */
129 ldap_value_free( refs );
136 if( rc != LDAP_SUCCESS ) {
139 if( ld->ld_matched != NULL ) {
140 LDAP_FREE( ld->ld_matched );
141 ld->ld_matched = NULL;
144 if( ld->ld_error != NULL ) {
145 LDAP_FREE( ld->ld_error );