}
if ( value == NULL ) {
- return 0;
+ return LDAP_SUCCESS;
}
if ( ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
break;
case LDAP_UNWILLING_TO_PERFORM:
- return -1;
-
case LDAP_OTHER:
- return -1;
+ return LDAP_OTHER;
}
} else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {
ber_memfree( vtmp.bv_val );
}
- return 0;
+ return LDAP_SUCCESS;
}
int
struct berval *fstr,
int remap )
{
- int i;
+ int i, rc;
Filter *p;
struct berval atmp;
struct berval vtmp;
ber_len_t len;
if ( f == NULL ) {
- ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr );
- return -1;
+ ber_str2bv( "(?=error)", sizeof("(?=error)")-1, 1, fstr );
+ return LDAP_OTHER;
}
switch ( f->f_choice ) {
case LDAP_FILTER_EQUALITY:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
- &f->f_av_value, &vtmp, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_av_desc, &atmp,
+ &f->f_av_value, &vtmp, remap );
+ if ( rc ) {
+ return rc;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
break;
case LDAP_FILTER_GE:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
- &f->f_av_value, &vtmp, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_av_desc, &atmp,
+ &f->f_av_value, &vtmp, remap );
+ if ( rc ) {
+ return rc;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
break;
case LDAP_FILTER_LE:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
- &f->f_av_value, &vtmp, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_av_desc, &atmp,
+ &f->f_av_value, &vtmp, remap );
+ if ( rc ) {
+ return rc;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
break;
case LDAP_FILTER_APPROX:
- if ( map_attr_value( dc, f->f_av_desc, &atmp,
- &f->f_av_value, &vtmp, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_av_desc, &atmp,
+ &f->f_av_value, &vtmp, remap );
+ if ( rc ) {
+ return rc;
}
fstr->bv_len = atmp.bv_len + vtmp.bv_len
break;
case LDAP_FILTER_SUBSTRINGS:
- if ( map_attr_value( dc, f->f_sub_desc, &atmp,
- NULL, NULL, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_sub_desc, &atmp,
+ NULL, NULL, remap );
+ if ( rc ) {
+ return rc;
}
/* cannot be a DN ... */
break;
case LDAP_FILTER_PRESENT:
- if ( map_attr_value( dc, f->f_desc, &atmp,
- NULL, NULL, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_desc, &atmp,
+ NULL, NULL, remap );
+ if ( rc ) {
+ return rc;
}
fstr->bv_len = atmp.bv_len + ( sizeof("(=*)") - 1 );
for ( p = f->f_list; p != NULL; p = p->f_next ) {
len = fstr->bv_len;
- if ( ldap_back_filter_map_rewrite( dc, p, &vtmp, remap ) )
- {
- return -1;
+ rc = ldap_back_filter_map_rewrite( dc, p, &vtmp, remap );
+ if ( rc != LDAP_SUCCESS ) {
+ return rc;
}
fstr->bv_len += vtmp.bv_len;
case LDAP_FILTER_EXT: {
if ( f->f_mr_desc ) {
- if ( map_attr_value( dc, f->f_mr_desc, &atmp,
- &f->f_mr_value, &vtmp, remap ) )
- {
- return -1;
+ rc = map_attr_value( dc, f->f_mr_desc, &atmp,
+ &f->f_mr_value, &vtmp, remap );
+ if ( rc ) {
+ return rc;
}
} else {
f->f_result == SLAPD_COMPARE_UNDEFINED ? sizeof("(?=undefined)")-1 :
sizeof("(?=error)")-1,
1, fstr );
- break;
+ return LDAP_COMPARE_FALSE;
default:
ber_str2bv( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr );
- break;
+ return LDAP_COMPARE_FALSE;
}
- return 0;
+ return LDAP_SUCCESS;
}
/*
struct metasingleconn *lsc;
struct timeval tv = { 0, 0 };
LDAPMessage *res, *e;
- int rc = 0, *msgid, sres = LDAP_NO_SUCH_OBJECT;
+ int rc = 0, *msgid, sres = LDAP_SUCCESS;
char *err = NULL;
struct berval match = { 0, NULL }, mmatch = { 0, NULL };
BerVarray v2refs = NULL;
int isroot = 0;
dncookie dc;
+ int is_scope = 0,
+ is_filter = 0;
+
/*
* controls are set in ldap_back_dobind()
*
if ( dnIsSuffix( &li->targets[ i ]->suffix,
&op->o_req_ndn ) ) {
realbase = li->targets[ i ]->suffix;
+ is_scope++;
+
} else {
/*
* this target is no longer candidate
*/
realbase = li->targets[ i ]->suffix;
realscope = LDAP_SCOPE_BASE;
+ is_scope++;
break;
} /* else continue with the next case */
rc = ldap_back_filter_map_rewrite( &dc,
op->oq_search.rs_filter,
&mfilter, BACKLDAP_MAP );
- if ( rc != 0 ) {
+ switch ( rc ) {
+ case LDAP_SUCCESS:
+ is_filter++;
+ break;
+
+ case LDAP_COMPARE_FALSE:
+ rc = 0;
+
+ default:
/*
* this target is no longer candidate
*/
* FIXME: we should handle error codes and return the more
* important/reasonable
*/
+ if ( is_scope == 0 ) {
+ sres = LDAP_NO_SUCH_OBJECT;
+ }
+
if ( sres == LDAP_SUCCESS && v2refs ) {
sres = LDAP_REFERRAL;
}