3 * Copyright (c) 1990 Regents of the University of Michigan.
6 * Redistribution and use in source and binary forms are permitted
7 * provided that this notice is preserved and that due credit is given
8 * to the University of Michigan at Ann Arbor. The name of the University
9 * may not be used to endorse or promote products derived from this
10 * software without specific prior written permission. This software
11 * is provided ``as is'' without express or implied warranty.
20 #include <ac/socket.h>
21 #include <ac/string.h>
23 #include <sys/ioctl.h>
25 #include <quipu/commonarg.h>
26 #include <quipu/ds_error.h>
33 * Print arbitrary stuff, for debugging.
40 bprint( char *data, int len )
42 static const char hexdig[] = "0123456789abcdef";
46 (void) memset( out, 0, BPLEN );
49 printf( "\t%s\n", ( i == 0 ) ? "(end)" : out );
53 if ( isgraph( (unsigned char)*data )) {
57 out[ i ] = hexdig[ ( (unsigned char)*data & 0xf0 ) >> 4 ];
58 out[ i+1 ] = hexdig[ (unsigned char)*data & 0x0f ];
64 if ( i > BPLEN - 2 ) {
65 printf( "\t%s\n", out );
66 (void) memset( out, 0, BPLEN );
75 charlist_free( char **cl )
82 for ( i = 0; cl[i] != NULL; i++ )
88 get_ava( BerElement *ber, AVA *tava )
92 Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
95 * An AVA looks like this:
96 * AttributeValueAsertion ::= SEQUENCE {
97 * attributeType AttributeType,
98 * attributeValue AttributeValue
102 if ( ber_scanf( ber, "{aa}", &type, &value ) == LBER_ERROR )
103 return( LDAP_PROTOCOL_ERROR );
105 if ( (tava->ava_type = str2AttrT( type )) == NULLAttrT ) {
108 return( LDAP_UNDEFINED_TYPE );
111 if ( (tava->ava_value = ldap_str2AttrV( value,
112 tava->ava_type->oa_syntax )) == NULLAttrV ) {
115 return( LDAP_INVALID_SYNTAX );
133 struct access_point *ap;
135 struct conn *save, *dup, *found;
137 Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );
140 dup = conn_dup( m->m_conn );
142 m->m_conn->c_ad = -1;
144 /* for each dsa candidate */
146 for ( cr = err->ERR_REFERRAL.DSE_ref_candidates;
147 cr != NULLCONTINUATIONREF; cr = cr->cr_next ) {
149 /* for each access point listed for the dsa */
150 for ( ap = cr->cr_accesspoints; ap != NULLACCESSPOINT;
153 if ( ldap_debug & LDAP_DEBUG_ARGS ) {
156 str = paddr2str( ap->ap_address, NULLNA );
157 fprintf( stderr, "Referring to (%s)...\n",
162 if ( m->m_conn->c_paddr )
163 free( (char *) m->m_conn->c_paddr );
164 m->m_conn->c_paddr = psap_cpy( ap->ap_address );
166 if ( (found = conn_find( m->m_conn )) != NULL ) {
167 conn_free( m->m_conn );
169 m->m_conn->c_refcnt++;
171 return( LDAP_SUCCESS );
174 rc = do_bind_real( m->m_conn, &bound, matched );
176 if ( rc == LDAP_SUCCESS ) {
178 conn_add( m->m_conn );
179 return( LDAP_SUCCESS );
185 /* so the conn can be found and freed later */
186 conn_free( m->m_conn );