/* search.c - DNS SRV backend search function */
/* $OpenLDAP$ */
/*
- * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
char **hosts = NULL;
char *refdn;
struct berval nrefdn = { 0, NULL };
- BVarray urls = NULL;
+ BerVarray urls = NULL;
assert( get_manageDSAit( op ) );
- if( ldap_dn2domain( dn->bv_val, &domain ) ) {
+ if( ldap_dn2domain( dn->bv_val, &domain ) || domain == NULL ) {
send_ldap_result( conn, op, LDAP_REFERRAL,
NULL, NULL, default_referral, NULL );
goto done;
}
Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=\"%s\" -> domain=\"%s\"\n",
- dn->bv_len ? dn->bv_val : "",
- domain == NULL ? "" : domain,
- 0 );
+ dn->bv_len ? dn->bv_val : "", domain, 0 );
- if( rc = ldap_domain2hostlist( domain, &hostlist ) ) {
+ if( ( rc = ldap_domain2hostlist( domain, &hostlist ) ) ) {
Debug( LDAP_DEBUG_TRACE, "DNSSRV: domain2hostlist returned %d\n",
rc, 0, 0 );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
goto done;
}
- hosts = str2charray( hostlist, " " );
+ hosts = ldap_str2charray( hostlist, " " );
if( hosts == NULL ) {
Debug( LDAP_DEBUG_TRACE, "DNSSRV: str2charrary error\n", 0, 0, 0 );
strcpy( url.bv_val, "ldap://" );
strcpy( &url.bv_val[sizeof("ldap://")-1], hosts[i] );
- if( bvarray_add( &urls, &url ) < 0 ) {
+ if( ber_bvarray_add( &urls, &url ) < 0 ) {
free( url.bv_val );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "problem processing DNS SRV records for DN",
}
Statslog( LDAP_DEBUG_STATS,
- "conn=%ld op=%d DNSSRV p=%d dn=\"%s\" url=\"%s\"\n",
+ "conn=%lu op=%lu DNSSRV p=%d dn=\"%s\" url=\"%s\"\n",
op->o_connid, op->o_opid, op->o_protocol,
dn->bv_len ? dn->bv_val : "", urls[0].bv_val );
}
}
- if( strcmp( nrefdn.bv_val, ndn->bv_val ) != 0 ) {
+ if( !dn_match( &nrefdn, ndn ) ) {
/* requested dn is subordinate */
Debug( LDAP_DEBUG_TRACE,
done:
if( domain != NULL ) ch_free( domain );
if( hostlist != NULL ) ch_free( hostlist );
- if( hosts != NULL ) charray_free( hosts );
- if( urls != NULL ) bvarray_free( urls );
+ if( hosts != NULL ) ldap_charray_free( hosts );
+ if( urls != NULL ) ber_bvarray_free( urls );
return 0;
}