*/
extern int
meta_back_is_candidate(
- struct berval *nsuffix,
- int suffixscope,
- BerVarray subtree_exclude,
+ metatarget_t *mt,
struct berval *ndn,
int scope );
*/
int
meta_back_is_candidate(
- struct berval *nsuffix,
- int suffixscope,
- BerVarray subtree_exclude,
+ metatarget_t *mt,
struct berval *ndn,
int scope )
{
- if ( dnIsSuffix( ndn, nsuffix ) ) {
- if ( subtree_exclude ) {
+ if ( dnIsSuffix( ndn, &mt->mt_nsuffix ) ) {
+ if ( mt->mt_subtree_exclude ) {
int i;
- for ( i = 0; !BER_BVISNULL( &subtree_exclude[ i ] ); i++ ) {
- if ( dnIsSuffix( ndn, &subtree_exclude[ i ] ) ) {
+ for ( i = 0; !BER_BVISNULL( &mt->mt_subtree_exclude[ i ] ); i++ ) {
+ if ( dnIsSuffix( ndn, &mt->mt_subtree_exclude[ i ] ) ) {
return META_NOT_CANDIDATE;
}
}
}
- switch ( suffixscope ) {
+ switch ( mt->mt_scope ) {
case LDAP_SCOPE_SUBTREE:
default:
return META_CANDIDATE;
case LDAP_SCOPE_SUBORDINATE:
- if ( ndn->bv_len > nsuffix->bv_len ) {
+ if ( ndn->bv_len > mt->mt_nsuffix.bv_len ) {
return META_CANDIDATE;
}
break;
/* nearly useless; not allowed by config */
case LDAP_SCOPE_ONELEVEL:
- if ( ndn->bv_len > nsuffix->bv_len ) {
+ if ( ndn->bv_len > mt->mt_nsuffix.bv_len ) {
struct berval rdn = *ndn;
- rdn.bv_len -= nsuffix->bv_len
+ rdn.bv_len -= mt->mt_nsuffix.bv_len
+ STRLENOF( "," );
if ( dnIsOneLevelRDN( &rdn ) ) {
return META_CANDIDATE;
/* nearly useless; not allowed by config */
case LDAP_SCOPE_BASE:
- if ( ndn->bv_len == nsuffix->bv_len ) {
+ if ( ndn->bv_len == mt->mt_nsuffix.bv_len ) {
return META_CANDIDATE;
}
break;
return META_NOT_CANDIDATE;
}
- if ( scope == LDAP_SCOPE_SUBTREE && dnIsSuffix( nsuffix, ndn ) ) {
+ if ( scope == LDAP_SCOPE_SUBTREE && dnIsSuffix( &mt->mt_nsuffix, ndn ) ) {
/*
* suffix longer than dn, but common part matches
*/
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metatarget_t *mt = mi->mi_targets[ i ];
- if ( meta_back_is_candidate( &mt->mt_nsuffix,
- mt->mt_scope,
- mt->mt_subtree_exclude,
- ndn, LDAP_SCOPE_BASE ) )
- {
+ if ( meta_back_is_candidate( mt, ndn, LDAP_SCOPE_BASE ) ) {
if ( candidate == META_TARGET_NONE ) {
candidate = i;
* and a default target is defined, and it is
* a candidate, try using it (FIXME: YMMV) */
if ( mi->mi_defaulttarget != META_DEFAULT_TARGET_NONE
- && meta_back_is_candidate( &mi->mi_targets[ mi->mi_defaulttarget ]->mt_nsuffix,
- mi->mi_targets[ mi->mi_defaulttarget ]->mt_scope,
- mi->mi_targets[ mi->mi_defaulttarget ]->mt_subtree_exclude,
+ && meta_back_is_candidate( mi->mi_targets[ mi->mi_defaulttarget ],
ndn, op->o_tag == LDAP_REQ_SEARCH ? op->ors_scope : LDAP_SCOPE_BASE ) )
{
candidate = mi->mi_defaulttarget;
metasingleconn_t *msc = &mc->mc_conns[ i ];
if ( i == cached
- || meta_back_is_candidate( &mt->mt_nsuffix,
- mt->mt_scope,
- mt->mt_subtree_exclude,
- &op->o_req_ndn,
- LDAP_SCOPE_SUBTREE ) )
+ || meta_back_is_candidate( mt, &op->o_req_ndn,
+ LDAP_SCOPE_SUBTREE ) )
{
/*
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metatarget_t *mt = mi->mi_targets[ candidate ];
- metaconn_t *mc = *mcp;
- metasingleconn_t *msc = &mc->mc_conns[ candidate ];
+ metasingleconn_t *msc = &(*mcp)->mc_conns[ candidate ];
struct berval realbase = op->o_req_dn;
int realscope = op->ors_scope;
- ber_len_t suffixlen = 0;
struct berval mbase = BER_BVNULL;
struct berval mfilter = BER_BVNULL;
char **mapped_attrs = NULL;
Debug( LDAP_DEBUG_TRACE, "%s >>> meta_back_search_start[%d]\n", op->o_log_prefix, candidate, 0 );
- /* should we check return values? */
- if ( op->ors_deref != -1 ) {
- assert( msc->msc_ld != NULL );
- (void)ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
- ( void * )&op->ors_deref );
- }
-
- if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
- tv.tv_sec = op->ors_tlimit > 0 ? op->ors_tlimit : 1;
- tv.tv_usec = 0;
- tvp = &tv;
- }
-
- dc->target = mt;
-
/*
* modifies the base according to the scope, if required
*/
- suffixlen = mt->mt_nsuffix.bv_len;
- if ( suffixlen > op->o_req_ndn.bv_len ) {
+ if ( mt->mt_nsuffix.bv_len > op->o_req_ndn.bv_len ) {
switch ( op->ors_scope ) {
case LDAP_SCOPE_SUBTREE:
/*
/*
* Rewrite the search base, if required
*/
+ dc->target = mt;
dc->ctx = "searchBase";
switch ( ldap_back_dn_massage( dc, &realbase, &mbase ) ) {
default:
goto done;
}
+ /* should we check return values? */
+ if ( op->ors_deref != -1 ) {
+ assert( msc->msc_ld != NULL );
+ (void)ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
+ ( void * )&op->ors_deref );
+ }
+
+ if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
+ tv.tv_sec = op->ors_tlimit > 0 ? op->ors_tlimit : 1;
+ tv.tv_usec = 0;
+ tvp = &tv;
+ }
+
/*
* Starts the search
*/