2 * Copyright (c) 1990 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
19 #include <ac/socket.h>
20 #include <ac/string.h>
22 #include <sys/ioctl.h>
24 #include <quipu/commonarg.h>
25 #include <quipu/ds_error.h>
32 * Print arbitrary stuff, for debugging.
39 bprint( char *data, int len )
41 static const char hexdig[] = "0123456789abcdef";
45 (void) memset( out, 0, BPLEN );
48 printf( "\t%s\n", ( i == 0 ) ? "(end)" : out );
52 if ( isgraph( (unsigned char)*data )) {
56 out[ i ] = hexdig[ ( (unsigned char)*data & 0xf0 ) >> 4 ];
57 out[ i+1 ] = hexdig[ (unsigned char)*data & 0x0f ];
63 if ( i > BPLEN - 2 ) {
64 printf( "\t%s\n", out );
65 (void) memset( out, 0, BPLEN );
74 charlist_free( char **cl )
81 for ( i = 0; cl[i] != NULL; i++ )
87 get_ava( BerElement *ber, AVA *tava )
91 Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
94 * An AVA looks like this:
95 * AttributeValueAsertion ::= SEQUENCE {
96 * attributeType AttributeType,
97 * attributeValue AttributeValue
101 if ( ber_scanf( ber, "{aa}", &type, &value ) == LBER_ERROR )
102 return( LDAP_PROTOCOL_ERROR );
104 if ( (tava->ava_type = str2AttrT( type )) == NULLAttrT ) {
107 return( LDAP_UNDEFINED_TYPE );
110 if ( (tava->ava_value = ldap_str2AttrV( value,
111 tava->ava_type->oa_syntax )) == NULLAttrV ) {
114 return( LDAP_INVALID_SYNTAX );
132 struct access_point *ap;
134 struct conn *save, *dup, *found;
136 Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );
139 dup = conn_dup( m->m_conn );
141 m->m_conn->c_ad = -1;
143 /* for each dsa candidate */
145 for ( cr = err->ERR_REFERRAL.DSE_ref_candidates;
146 cr != NULLCONTINUATIONREF; cr = cr->cr_next ) {
148 /* for each access point listed for the dsa */
149 for ( ap = cr->cr_accesspoints; ap != NULLACCESSPOINT;
152 if ( ldap_debug & LDAP_DEBUG_ARGS ) {
155 str = paddr2str( ap->ap_address, NULLNA );
156 fprintf( stderr, "Referring to (%s)...\n",
161 if ( m->m_conn->c_paddr )
162 free( (char *) m->m_conn->c_paddr );
163 m->m_conn->c_paddr = psap_cpy( ap->ap_address );
165 if ( (found = conn_find( m->m_conn )) != NULL ) {
166 conn_free( m->m_conn );
168 m->m_conn->c_refcnt++;
170 return( LDAP_SUCCESS );
173 rc = do_bind_real( m->m_conn, &bound, matched );
175 if ( rc == LDAP_SUCCESS ) {
177 conn_add( m->m_conn );
178 return( LDAP_SUCCESS );
184 /* so the conn can be found and freed later */
185 conn_free( m->m_conn );