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.
16 #include <sys/errno.h>
17 #include <sys/ioctl.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <quipu/commonarg.h>
21 #include <quipu/ds_error.h>
27 * Print arbitrary stuff, for debugging.
34 bprint( char *data, int len )
36 static char hexdig[] = "0123456789abcdef";
40 (void) memset( out, 0, BPLEN );
43 printf( "\t%s\n", ( i == 0 ) ? "(end)" : out );
47 if ( isgraph( (unsigned char)*data )) {
51 out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
52 out[ i+1 ] = hexdig[ *data & 0x0f ];
58 if ( i > BPLEN - 2 ) {
59 printf( "\t%s\n", out );
60 (void) memset( out, 0, BPLEN );
68 void charlist_free( char **cl )
75 for ( i = 0; cl[i] != NULL; i++ )
81 get_ava( BerElement *ber, AVA *tava )
84 extern short ldap_dn_syntax;
86 Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
89 * An AVA looks like this:
90 * AttributeValueAsertion ::= SEQUENCE {
91 * attributeType AttributeType,
92 * attributeValue AttributeValue
96 if ( ber_scanf( ber, "{aa}", &type, &value ) == LBER_ERROR )
97 return( LDAP_PROTOCOL_ERROR );
99 if ( (tava->ava_type = str2AttrT( type )) == NULLAttrT ) {
102 return( LDAP_UNDEFINED_TYPE );
105 if ( (tava->ava_value = ldap_str2AttrV( value,
106 tava->ava_type->oa_syntax )) == NULLAttrV ) {
109 return( LDAP_INVALID_SYNTAX );
127 struct access_point *ap;
129 struct conn *save, *dup, *found;
130 struct PSAPaddr *psap_cpy();
132 Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );
135 dup = conn_dup( m->m_conn );
137 m->m_conn->c_ad = -1;
139 /* for each dsa candidate */
141 for ( cr = err->ERR_REFERRAL.DSE_ref_candidates;
142 cr != NULLCONTINUATIONREF; cr = cr->cr_next ) {
144 /* for each access point listed for the dsa */
145 for ( ap = cr->cr_accesspoints; ap != NULLACCESSPOINT;
148 if ( ldap_debug & LDAP_DEBUG_ARGS ) {
151 str = paddr2str( ap->ap_address, NULLNA );
152 fprintf( stderr, "Referring to (%s)...\n",
157 if ( m->m_conn->c_paddr )
158 free( (char *) m->m_conn->c_paddr );
159 m->m_conn->c_paddr = psap_cpy( ap->ap_address );
161 if ( (found = conn_find( m->m_conn )) != NULL ) {
162 conn_free( m->m_conn );
164 m->m_conn->c_refcnt++;
166 return( LDAP_SUCCESS );
169 rc = do_bind_real( m->m_conn, &bound, matched );
171 if ( rc == LDAP_SUCCESS ) {
173 conn_add( m->m_conn );
174 return( LDAP_SUCCESS );
180 /* so the conn can be found and freed later */
181 conn_free( m->m_conn );