11 #include <ac/socket.h>
12 #include <ac/string.h>
19 ldap_first_reference( LDAP *ld, LDAPMessage *chain )
21 if ( ld == NULL || chain == NULLMSG ) {
25 return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
27 : ldap_next_reference( ld, chain );
32 ldap_next_reference( LDAP *ld, LDAPMessage *ref )
34 if ( ld == NULL || ref == NULLMSG ) {
43 if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
53 ldap_count_references( LDAP *ld, LDAPMessage *chain )
61 for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
62 if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
75 LDAPControl ***serverctrls,
82 if( ld == NULL || ref == NULL ||
83 ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE )
85 return LDAP_PARAM_ERROR;
88 /* make a private copy of BerElement */
89 SAFEMEMCPY(&be, ref->lm_ber, sizeof(be));
91 if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) {
92 rc = LDAP_DECODING_ERROR;
96 if ( serverctrls == NULL ) {
101 if ( ber_scanf( &be, /*{*/ "}" ) == LBER_ERROR ) {
102 rc = LDAP_DECODING_ERROR;
103 goto free_and_return;
106 rc = ldap_get_ber_controls( &be, serverctrls );
110 if( referralsp != NULL ) {
111 /* provide references regradless of return code */
115 ldap_value_free( refs );
122 if( rc != LDAP_SUCCESS ) {
125 if( ld->ld_matched != NULL )
126 free( ld->ld_matched );
128 ld->ld_matched = NULL;
130 if( ld->ld_error != NULL )
131 free( ld->ld_error );