int n_attrs = 0;
AttributeName *an = NULL;
- if ( bsi->attrs == NULL ) {
+ if ( bsi->bsi_attrs == NULL ) {
return 1;
}
* clear the list (retrieve all attrs)
*/
if ( ad == NULL ) {
- ch_free( bsi->attrs );
- bsi->attrs = NULL;
+ ch_free( bsi->bsi_attrs );
+ bsi->bsi_attrs = NULL;
return 1;
}
- for ( ; bsi->attrs[ n_attrs ].an_name.bv_val; n_attrs++ ) {
- an = &bsi->attrs[ n_attrs ];
+ for ( ; bsi->bsi_attrs[ n_attrs ].an_name.bv_val; n_attrs++ ) {
+ an = &bsi->bsi_attrs[ n_attrs ];
Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
"attribute '%s' is in list\n",
Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
"adding '%s' to list\n", ad->ad_cname.bv_val, 0, 0 );
- an = (AttributeName *)ch_realloc( bsi->attrs,
+ an = (AttributeName *)ch_realloc( bsi->bsi_attrs,
sizeof( AttributeName ) * ( n_attrs + 2 ) );
if ( an == NULL ) {
return -1;
an[ n_attrs + 1 ].an_name.bv_val = NULL;
an[ n_attrs + 1 ].an_name.bv_len = 0;
- bsi->attrs = an;
+ bsi->bsi_attrs = an;
return 1;
}
{
AttributeName *p;
- bsi->base_dn = base;
- bsi->scope = scope;
- bsi->slimit = slimit;
- bsi->tlimit = tlimit;
- bsi->filter = filter;
- bsi->dbh = dbh;
- bsi->op = op;
+ bsi->bsi_base_dn = base;
+ bsi->bsi_scope = scope;
+ bsi->bsi_slimit = slimit;
+ bsi->bsi_tlimit = tlimit;
+ bsi->bsi_filter = filter;
+ bsi->bsi_dbh = dbh;
+ bsi->bsi_op = op;
bsi->bsi_flags = 0;
/*
* handle "*"
*/
if ( attrs == NULL || an_find( attrs, &AllUser ) ) {
- bsi->attrs = NULL;
+ bsi->bsi_attrs = NULL;
} else {
- bsi->attrs = (AttributeName *)ch_calloc( 1,
+ bsi->bsi_attrs = (AttributeName *)ch_calloc( 1,
sizeof( AttributeName ) );
- bsi->attrs[ 0 ].an_name.bv_val = NULL;
- bsi->attrs[ 0 ].an_name.bv_len = 0;
+ bsi->bsi_attrs[ 0 ].an_name.bv_val = NULL;
+ bsi->bsi_attrs[ 0 ].an_name.bv_len = 0;
for ( p = attrs; p->an_name.bv_val; p++ ) {
/*
}
}
- bsi->abandon = 0;
- bsi->id_list = NULL;
- bsi->n_candidates = 0;
- bsi->stoptime = stoptime;
- bsi->sel.bb_val.bv_val = NULL;
- bsi->sel.bb_val.bv_len = 0;
- bsi->sel.bb_len = 0;
- bsi->from.bb_val.bv_val = NULL;
- bsi->from.bb_val.bv_len = 0;
- bsi->from.bb_len = 0;
- bsi->join_where.bb_val.bv_val = NULL;
- bsi->join_where.bb_val.bv_len = 0;
- bsi->join_where.bb_len = 0;
- bsi->flt_where.bb_val.bv_val = NULL;
- bsi->flt_where.bb_val.bv_len = 0;
- bsi->flt_where.bb_len = 0;
-
- bsi->status = LDAP_SUCCESS;
+ bsi->bsi_abandon = 0;
+ bsi->bsi_id_list = NULL;
+ bsi->bsi_n_candidates = 0;
+ bsi->bsi_stoptime = stoptime;
+ bsi->bsi_sel.bb_val.bv_val = NULL;
+ bsi->bsi_sel.bb_val.bv_len = 0;
+ bsi->bsi_sel.bb_len = 0;
+ bsi->bsi_from.bb_val.bv_val = NULL;
+ bsi->bsi_from.bb_val.bv_len = 0;
+ bsi->bsi_from.bb_len = 0;
+ bsi->bsi_join_where.bb_val.bv_val = NULL;
+ bsi->bsi_join_where.bb_val.bv_len = 0;
+ bsi->bsi_join_where.bb_len = 0;
+ bsi->bsi_flt_where.bb_val.bv_val = NULL;
+ bsi->bsi_flt_where.bb_val.bv_len = 0;
+ bsi->bsi_flt_where.bb_len = 0;
+ bsi->bsi_filter_oc = NULL;
+
+ bsi->bsi_status = LDAP_SUCCESS;
}
static int
return 0;
}
- backsql_strfcat( &bsi->flt_where, "c", '(' /* ) */ );
+ backsql_strfcat( &bsi->bsi_flt_where, "c", '(' /* ) */ );
while ( 1 ) {
res = backsql_process_filter( bsi, f );
switch ( op ) {
case LDAP_FILTER_AND:
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( " AND " ) - 1,
" AND " );
break;
case LDAP_FILTER_OR:
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( " OR " ) - 1,
" OR " );
break;
}
}
- backsql_strfcat( &bsi->flt_where, "c", /* ( */ ')' );
+ backsql_strfcat( &bsi->bsi_flt_where, "c", /* ( */ ')' );
return 1;
}
{
int i;
backsql_at_map_rec *at;
- backsql_info *bi = (backsql_info *)bsi->op->o_bd->be_private;
+ backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int casefold = 0;
if ( !f ) {
casefold = 1;
}
- at = backsql_ad2at( bsi->oc, f->f_sub_desc );
+ at = backsql_ad2at( bsi->bsi_oc, f->f_sub_desc );
assert( at );
* SQL filters are more liberal.
*/
- backsql_strfcat( &bsi->flt_where, "c", '(' /* ) */ );
+ backsql_strfcat( &bsi->bsi_flt_where, "c", '(' /* ) */ );
/* TimesTen */
Debug( LDAP_DEBUG_TRACE, "expr: '%s' '%s'\n", at->sel_expr.bv_val,
* If a pre-upper-cased version of the column exists, use it
*/
if ( at->sel_expr_u.bv_val ) {
- backsql_strfcat( &bsi->flt_where,
+ backsql_strfcat( &bsi->bsi_flt_where,
"bl",
&at->sel_expr_u,
(ber_len_t)sizeof( " LIKE '" ) - 1,
" LIKE '" );
} else {
- backsql_strfcat( &bsi->flt_where,
+ backsql_strfcat( &bsi->bsi_flt_where,
"bcbcl",
&bi->upper_func,
'(',
" LIKE '" );
}
} else {
- backsql_strfcat( &bsi->flt_where, "bl",
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
&at->sel_expr,
(ber_len_t)sizeof( " LIKE '" ) - 1, " LIKE '" );
}
if ( f->f_sub_initial.bv_val != NULL ) {
size_t start;
- start = bsi->flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where, "b",
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+ backsql_strfcat( &bsi->bsi_flt_where, "b",
&f->f_sub_initial );
if ( casefold && bi->upper_func.bv_val ) {
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
}
}
- backsql_strfcat( &bsi->flt_where, "c", '%' );
+ backsql_strfcat( &bsi->bsi_flt_where, "c", '%' );
if ( f->f_sub_any != NULL ) {
for ( i = 0; f->f_sub_any[ i ].bv_val != NULL; i++ ) {
0, 0 );
#endif /* BACKSQL_TRACE */
- start = bsi->flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where,
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+ backsql_strfcat( &bsi->bsi_flt_where,
"bc",
&f->f_sub_any[ i ],
'%' );
/*
* Note: toupper('%') = '%'
*/
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
}
}
if ( f->f_sub_final.bv_val != NULL ) {
size_t start;
- start = bsi->flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where, "b",
+ start = bsi->bsi_flt_where.bb_val.bv_len;
+ backsql_strfcat( &bsi->bsi_flt_where, "b",
&f->f_sub_final );
if ( casefold && bi->upper_func.bv_val ) {
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
}
}
}
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( /* (' */ "')" ) - 1, /* ( */ "')" );
return 1;
static int
backsql_process_filter( backsql_srch_info *bsi, Filter *f )
{
- backsql_info *bi = (backsql_info *)bsi->op->o_bd->be_private;
+ backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
backsql_at_map_rec *at;
backsql_at_map_rec oc_attr = {
slap_schema.si_ad_objectClass, BER_BVC(""), BER_BVC(""),
break;
case LDAP_FILTER_NOT:
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( "NOT (" /* ) */ ) - 1,
"NOT (" /* ) */ );
rc = backsql_process_filter( bsi, f->f_not );
- backsql_strfcat( &bsi->flt_where, "c", /* ( */ ')' );
+ backsql_strfcat( &bsi->bsi_flt_where, "c", /* ( */ ')' );
done = 1;
break;
at = &oc_attr;
backsql_strfcat( &bb, "cbc",
'\'',
- &bsi->oc->oc->soc_cname,
+ &bsi->bsi_oc->oc->soc_cname,
'\'' );
at->sel_expr = bb.bb_val;
* selecting if there are descendants of the
* candidate.
*/
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
if ( ad == slap_schema.si_ad_hasSubordinates ) {
/*
goto done;
} else {
- at = backsql_ad2at( bsi->oc, ad );
+ at = backsql_ad2at( bsi->bsi_oc, ad );
}
if ( at == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_process_filter(): "
"attribute '%s' is not defined for objectclass '%s'\n",
- ad->ad_cname.bv_val, BACKSQL_OC_NAME( bsi->oc ), 0 );
- backsql_strfcat( &bsi->flt_where, "l",
+ ad->ad_cname.bv_val, BACKSQL_OC_NAME( bsi->bsi_oc ), 0 );
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( "1=0" ) - 1, "1=0" );
+ bsi->bsi_status = LDAP_UNDEFINED_TYPE;
goto impossible;
}
- backsql_merge_from_clause( &bsi->from, &at->from_tbls );
+ backsql_merge_from_clause( &bsi->bsi_from, &at->from_tbls );
/*
* need to add this attribute to list of attrs to load,
- * so that we could do test_filter() later
+ * so that we can do test_filter() later
*/
backsql_attrlist_add( bsi, ad );
if ( at->join_where.bv_val != NULL
- && strstr( bsi->join_where.bb_val.bv_val, at->join_where.bv_val ) == NULL ) {
- backsql_strfcat( &bsi->join_where, "lb",
+ && strstr( bsi->bsi_join_where.bb_val.bv_val, at->join_where.bv_val ) == NULL ) {
+ backsql_strfcat( &bsi->bsi_join_where, "lb",
(ber_len_t)sizeof( " AND " ) - 1, " AND ",
&at->join_where );
}
casefold = 1;
}
+ /*
+ * objectClass inheritance:
+ * - a search for "person" will also return "inetOrgPerson"
+ * - a search for "top" will return everything
+ */
+ if ( at == &oc_attr ) {
+ ObjectClass *oc = oc_bvfind( filter_value );
+
+ rc = is_object_subclass( oc, bsi->bsi_oc->oc );
+ if ( rc ) {
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
+ sizeof( "(1=1)" ) - 1, "(1=1)" );
+ break;
+
+ } else {
+ rc = -1;
+ goto impossible;
+ }
+ }
+
/*
* maybe we should check type of at->sel_expr here somehow,
* to know whether upper_func is applicable, but for now
size_t start;
if ( at->sel_expr_u.bv_val ) {
- backsql_strfcat( &bsi->flt_where, "cbl",
- '(',
+ backsql_strfcat( &bsi->bsi_flt_where, "cbl",
+ '(', /* ) */
&at->sel_expr_u,
(ber_len_t)sizeof( "='" ) - 1,
"='" );
} else {
- backsql_strfcat( &bsi->flt_where, "cbcbl",
+ backsql_strfcat( &bsi->bsi_flt_where, "cbcbl",
'(' /* ) */ ,
&bi->upper_func,
'(' /* ) */ ,
/* ( */ ")='" );
}
- start = bsi->flt_where.bb_val.bv_len;
+ start = bsi->bsi_flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where, "bl",
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
filter_value,
(ber_len_t)sizeof( /* (' */ "')" ) - 1,
/* (' */ "')" );
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
} else {
- backsql_strfcat( &bsi->flt_where, "cblbl",
+ backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
'(',
&at->sel_expr,
(ber_len_t)sizeof( "='" ) - 1, "='",
size_t start;
if ( at->sel_expr_u.bv_val ) {
- backsql_strfcat( &bsi->flt_where, "cbbc",
+ backsql_strfcat( &bsi->bsi_flt_where, "cbbc",
'(',
&at->sel_expr_u,
&ordering,
'\'' );
} else {
- backsql_strfcat( &bsi->flt_where, "cbcbcbc",
+ backsql_strfcat( &bsi->bsi_flt_where, "cbcbcbc",
'(' /* ) */ ,
&bi->upper_func,
'(' /* ) */ ,
'\'' );
}
- start = bsi->flt_where.bb_val.bv_len;
+ start = bsi->bsi_flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where, "bl",
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
filter_value,
(ber_len_t)sizeof( /* (' */ "')" ) - 1,
/* (' */ "')" );
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
} else {
- backsql_strfcat( &bsi->flt_where, "cbbcbl",
+ backsql_strfcat( &bsi->bsi_flt_where, "cbbcbl",
'(' /* ) */ ,
&at->sel_expr,
&ordering,
break;
case LDAP_FILTER_PRESENT:
- backsql_strfcat( &bsi->flt_where, "lbl",
- (ber_len_t)sizeof( "NOT (" ) - 1, "NOT (",
+ backsql_strfcat( &bsi->bsi_flt_where, "lbl",
+ (ber_len_t)sizeof( "NOT (" /* ) */) - 1,
+ "NOT (", /* ) */
&at->sel_expr,
- (ber_len_t)sizeof( " IS NULL)" ) - 1, " IS NULL)" );
+ (ber_len_t)sizeof( /* ( */ " IS NULL)" ) - 1,
+ /* ( */ " IS NULL)" );
break;
case LDAP_FILTER_SUBSTRINGS:
size_t start;
if ( at->sel_expr_u.bv_val ) {
- backsql_strfcat( &bsi->flt_where, "cbl",
- '(',
+ backsql_strfcat( &bsi->bsi_flt_where, "cbl",
+ '(', /* ) */
&at->sel_expr_u,
(ber_len_t)sizeof( " LIKE '%" ) - 1,
" LIKE '%" );
} else {
- backsql_strfcat( &bsi->flt_where, "cbcbl",
+ backsql_strfcat( &bsi->bsi_flt_where, "cbcbl",
'(' /* ) */ ,
&bi->upper_func,
'(' /* ) */ ,
/* ( */ ") LIKE '%" );
}
- start = bsi->flt_where.bb_val.bv_len;
+ start = bsi->bsi_flt_where.bb_val.bv_len;
- backsql_strfcat( &bsi->flt_where, "bl",
+ backsql_strfcat( &bsi->bsi_flt_where, "bl",
&f->f_av_value,
(ber_len_t)sizeof( /* (' */ "%')" ) - 1,
/* (' */ "%')" );
- ldap_pvt_str2upper( &bsi->flt_where.bb_val.bv_val[ start ] );
+ ldap_pvt_str2upper( &bsi->bsi_flt_where.bb_val.bv_val[ start ] );
} else {
- backsql_strfcat( &bsi->flt_where, "cblbl",
- '(',
+ backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
+ '(', /* ) */
&at->sel_expr,
(ber_len_t)sizeof( " LIKE '%" ) - 1,
" LIKE '%",
default:
/* unhandled filter type; should not happen */
assert( 0 );
- backsql_strfcat( &bsi->flt_where, "l",
+ backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
break;
static int
backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
{
- backsql_info *bi = (backsql_info *)bsi->op->o_bd->be_private;
+ backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int rc;
assert( query );
query->bv_len = 0;
Debug( LDAP_DEBUG_TRACE, "==>backsql_srch_query()\n", 0, 0, 0 );
- bsi->sel.bb_val.bv_val = NULL;
- bsi->sel.bb_val.bv_len = 0;
- bsi->sel.bb_len = 0;
- bsi->from.bb_val.bv_val = NULL;
- bsi->from.bb_val.bv_len = 0;
- bsi->from.bb_len = 0;
- bsi->join_where.bb_val.bv_val = NULL;
- bsi->join_where.bb_val.bv_len = 0;
- bsi->join_where.bb_len = 0;
- bsi->flt_where.bb_val.bv_val = NULL;
- bsi->flt_where.bb_val.bv_len = 0;
- bsi->flt_where.bb_len = 0;
-
- backsql_strfcat( &bsi->sel, "lbcbc",
+ bsi->bsi_sel.bb_val.bv_val = NULL;
+ bsi->bsi_sel.bb_val.bv_len = 0;
+ bsi->bsi_sel.bb_len = 0;
+ bsi->bsi_from.bb_val.bv_val = NULL;
+ bsi->bsi_from.bb_val.bv_len = 0;
+ bsi->bsi_from.bb_len = 0;
+ bsi->bsi_join_where.bb_val.bv_val = NULL;
+ bsi->bsi_join_where.bb_val.bv_len = 0;
+ bsi->bsi_join_where.bb_len = 0;
+ bsi->bsi_flt_where.bb_val.bv_val = NULL;
+ bsi->bsi_flt_where.bb_val.bv_len = 0;
+ bsi->bsi_flt_where.bb_len = 0;
+
+ backsql_strfcat( &bsi->bsi_sel, "lbcbc",
(ber_len_t)sizeof( "SELECT DISTINCT ldap_entries.id," ) - 1,
"SELECT DISTINCT ldap_entries.id,",
- &bsi->oc->keytbl,
+ &bsi->bsi_oc->keytbl,
'.',
- &bsi->oc->keycol,
+ &bsi->bsi_oc->keycol,
',' );
if ( bi->strcast_func.bv_val ) {
- backsql_strfcat( &bsi->sel, "blbl",
+ backsql_strfcat( &bsi->bsi_sel, "blbl",
&bi->strcast_func,
(ber_len_t)sizeof( "('" /* ') */ ) - 1,
"('" /* ') */ ,
- &bsi->oc->oc->soc_cname,
+ &bsi->bsi_oc->oc->soc_cname,
(ber_len_t)sizeof( /* (' */ "')" ) - 1,
/* (' */ "')" );
} else {
- backsql_strfcat( &bsi->sel, "cbc",
+ backsql_strfcat( &bsi->bsi_sel, "cbc",
'\'',
- &bsi->oc->oc->soc_cname,
+ &bsi->bsi_oc->oc->soc_cname,
'\'' );
}
- backsql_strfcat( &bsi->sel, "l",
+ backsql_strfcat( &bsi->bsi_sel, "l",
(ber_len_t)sizeof( " AS objectClass,ldap_entries.dn AS dn" ) - 1,
" AS objectClass,ldap_entries.dn AS dn" );
- backsql_strfcat( &bsi->from, "lb",
+ backsql_strfcat( &bsi->bsi_from, "lb",
(ber_len_t)sizeof( " FROM ldap_entries," ) - 1,
" FROM ldap_entries,",
- &bsi->oc->keytbl );
+ &bsi->bsi_oc->keytbl );
- backsql_strfcat( &bsi->join_where, "lbcbl",
+ backsql_strfcat( &bsi->bsi_join_where, "lbcbl",
(ber_len_t)sizeof( " WHERE " ) - 1, " WHERE ",
- &bsi->oc->keytbl,
+ &bsi->bsi_oc->keytbl,
'.',
- &bsi->oc->keycol,
+ &bsi->bsi_oc->keycol,
(ber_len_t)sizeof( "=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND " ) - 1,
"=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND " );
- switch ( bsi->scope ) {
+ switch ( bsi->bsi_scope ) {
case LDAP_SCOPE_BASE:
if ( bi->upper_func.bv_val ) {
- backsql_strfcat( &bsi->join_where, "blbcb",
+ backsql_strfcat( &bsi->bsi_join_where, "blbcb",
&bi->upper_func,
(ber_len_t)sizeof( "(ldap_entries.dn)=" ) - 1,
"(ldap_entries.dn)=",
'?',
&bi->upper_func_close );
} else {
- backsql_strfcat( &bsi->join_where, "l",
+ backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.dn=?" ) - 1,
"ldap_entries.dn=?" );
}
break;
case LDAP_SCOPE_ONELEVEL:
- backsql_strfcat( &bsi->join_where, "l",
+ backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.parent=?" ) - 1,
"ldap_entries.parent=?" );
break;
case LDAP_SCOPE_SUBTREE:
if ( bi->upper_func.bv_val ) {
- backsql_strfcat( &bsi->join_where, "blbcb",
+ backsql_strfcat( &bsi->bsi_join_where, "blbcb",
&bi->upper_func,
(ber_len_t)sizeof( "(ldap_entries.dn) LIKE " ) - 1,
"(ldap_entries.dn) LIKE ",
'?',
&bi->upper_func_close );
} else {
- backsql_strfcat( &bsi->join_where, "l",
+ backsql_strfcat( &bsi->bsi_join_where, "l",
(ber_len_t)sizeof( "ldap_entries.dn LIKE ?" ) - 1,
"ldap_entries.dn LIKE ?" );
}
assert( 0 );
}
- rc = backsql_process_filter( bsi, bsi->filter );
+ rc = backsql_process_filter( bsi, bsi->bsi_filter );
if ( rc > 0 ) {
struct berbuf bb = BB_NULL;
backsql_strfcat( &bb, "bbblb",
- &bsi->sel.bb_val,
- &bsi->from.bb_val,
- &bsi->join_where.bb_val,
+ &bsi->bsi_sel.bb_val,
+ &bsi->bsi_from.bb_val,
+ &bsi->bsi_join_where.bb_val,
(ber_len_t)sizeof( " AND " ) - 1, " AND ",
- &bsi->flt_where.bb_val );
+ &bsi->bsi_flt_where.bb_val );
*query = bb.bb_val;
query->bv_val = NULL;
}
- free( bsi->sel.bb_val.bv_val );
- bsi->sel.bb_val.bv_len = 0;
- bsi->sel.bb_len = 0;
- free( bsi->from.bb_val.bv_val );
- bsi->from.bb_val.bv_len = 0;
- bsi->from.bb_len = 0;
- free( bsi->join_where.bb_val.bv_val );
- bsi->join_where.bb_val.bv_len = 0;
- bsi->join_where.bb_len = 0;
- free( bsi->flt_where.bb_val.bv_val );
- bsi->flt_where.bb_val.bv_len = 0;
- bsi->flt_where.bb_len = 0;
+ free( bsi->bsi_sel.bb_val.bv_val );
+ bsi->bsi_sel.bb_val.bv_len = 0;
+ bsi->bsi_sel.bb_len = 0;
+ free( bsi->bsi_from.bb_val.bv_val );
+ bsi->bsi_from.bb_val.bv_len = 0;
+ bsi->bsi_from.bb_len = 0;
+ free( bsi->bsi_join_where.bb_val.bv_val );
+ bsi->bsi_join_where.bb_val.bv_len = 0;
+ bsi->bsi_join_where.bb_len = 0;
+ free( bsi->bsi_flt_where.bb_val.bv_val );
+ bsi->bsi_flt_where.bb_val.bv_len = 0;
+ bsi->bsi_flt_where.bb_len = 0;
Debug( LDAP_DEBUG_TRACE, "<==backsql_srch_query() returns %s\n",
query->bv_val ? query->bv_val : "NULL", 0, 0 );
{
backsql_oc_map_rec *oc = v_oc;
backsql_srch_info *bsi = v_bsi;
- backsql_info *bi = (backsql_info *)bsi->op->o_bd->be_private;
+ backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
struct berval query;
SQLHSTMT sth;
RETCODE rc;
int i;
int j;
- int n_candidates = bsi->n_candidates;
+ int n_candidates = bsi->bsi_n_candidates;
- bsi->status = LDAP_SUCCESS;
+ bsi->bsi_status = LDAP_SUCCESS;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_oc_get_candidates(): oc='%s'\n",
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_oc_get_candidates(): oc='%s'\n",
BACKSQL_OC_NAME( oc ), 0, 0 );
- if ( bsi->n_candidates == -1 ) {
+ if ( bsi->bsi_n_candidates == -1 ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"unchecked limit has been overcome\n", 0, 0, 0 );
/* should never get here */
assert( 0 );
- bsi->status = LDAP_ADMINLIMIT_EXCEEDED;
+ bsi->bsi_status = LDAP_ADMINLIMIT_EXCEEDED;
return BACKSQL_STOP;
}
- bsi->oc = oc;
+ bsi->bsi_oc = oc;
res = backsql_srch_query( bsi, &query );
if ( res ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
* FIXME: need to separate errors from legally
* impossible filters
*/
- bsi->status = LDAP_SUCCESS;
- return BACKSQL_CONTINUE;
+ switch ( bsi->bsi_status ) {
+ case LDAP_SUCCESS:
+ case LDAP_UNDEFINED_TYPE:
+ case LDAP_NO_SUCH_OBJECT:
+ /* we are conservative... */
+ default:
+ bsi->bsi_status = LDAP_SUCCESS;
+ /* try next */
+ return BACKSQL_CONTINUE;
+
+ case LDAP_ADMINLIMIT_EXCEEDED:
+ case LDAP_OTHER:
+ /* don't try any more */
+ return BACKSQL_STOP;
+ }
}
if ( query.bv_val == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"could not construct query for objectclass '%s'\n",
oc->oc->soc_cname.bv_val, 0, 0 );
- bsi->status = LDAP_SUCCESS;
+ bsi->bsi_status = LDAP_SUCCESS;
return BACKSQL_CONTINUE;
}
Debug( LDAP_DEBUG_TRACE, "Constructed query: %s\n",
query.bv_val, 0, 0 );
- rc = backsql_Prepare( bsi->dbh, &sth, query.bv_val, 0 );
+ rc = backsql_Prepare( bsi->bsi_dbh, &sth, query.bv_val, 0 );
free( query.bv_val );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error preparing query\n", 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, bsi->dbh, sth, rc );
- bsi->status = LDAP_OTHER;
+ backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc );
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
- Debug( LDAP_DEBUG_TRACE, "id: '%ld'\n", bsi->oc->id, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "id: '%ld'\n", bsi->bsi_oc->id, 0, 0 );
- if ( backsql_BindParamID( sth, 1, &bsi->oc->id ) != SQL_SUCCESS ) {
+ if ( backsql_BindParamID( sth, 1, &bsi->bsi_oc->id ) != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error binding objectclass id parameter\n", 0, 0, 0 );
- bsi->status = LDAP_OTHER;
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
- switch ( bsi->scope ) {
+ switch ( bsi->bsi_scope ) {
case LDAP_SCOPE_BASE:
Debug( LDAP_DEBUG_TRACE, "(base)dn: '%s'\n",
- bsi->base_dn->bv_val, 0, 0 );
+ bsi->bsi_base_dn->bv_val, 0, 0 );
- rc = backsql_BindParamStr( sth, 2, bsi->base_dn->bv_val,
+ rc = backsql_BindParamStr( sth, 2, bsi->bsi_base_dn->bv_val,
BACKSQL_MAX_DN_LEN );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error binding base_dn parameter\n", 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, bsi->dbh,
+ backsql_PrintErrors( bi->db_env, bsi->bsi_dbh,
sth, rc );
- bsi->status = LDAP_OTHER;
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
break;
* We do not accept DNs longer than BACKSQL_MAX_DN_LEN;
* however this should be handled earlier
*/
- assert( bsi->base_dn->bv_len <= BACKSQL_MAX_DN_LEN );
+ assert( bsi->bsi_base_dn->bv_len <= BACKSQL_MAX_DN_LEN );
/*
* Sets the parameters for the SQL built earlier
*/
if ( BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ) {
temp_base_dn[ 0 ] = '\0';
- for ( i = 0, j = bsi->base_dn->bv_len - 1;
+ for ( i = 0, j = bsi->bsi_base_dn->bv_len - 1;
j >= 0; i++, j--) {
- temp_base_dn[ i ] = bsi->base_dn->bv_val[ j ];
+ temp_base_dn[ i ] = bsi->bsi_base_dn->bv_val[ j ];
}
temp_base_dn[ i ] = '%';
temp_base_dn[ i + 1 ] = '\0';
} else {
temp_base_dn[ 0 ] = '%';
- AC_MEMCPY( &temp_base_dn[ 1 ], bsi->base_dn->bv_val,
- bsi->base_dn->bv_len + 1 );
+ AC_MEMCPY( &temp_base_dn[ 1 ], bsi->bsi_base_dn->bv_val,
+ bsi->bsi_base_dn->bv_len + 1 );
}
ldap_pvt_str2upper( temp_base_dn );
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error binding base_dn parameter (2)\n",
0, 0, 0 );
- backsql_PrintErrors( bi->db_env, bsi->dbh,
+ backsql_PrintErrors( bi->db_env, bsi->bsi_dbh,
sth, rc );
- bsi->status = LDAP_OTHER;
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
break;
case LDAP_SCOPE_ONELEVEL:
res = backsql_dn2id( bi, &base_id,
- bsi->dbh, bsi->base_dn );
+ bsi->bsi_dbh, bsi->bsi_base_dn );
if ( res != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"could not retrieve base_dn id%s\n",
res == LDAP_NO_SUCH_OBJECT ? ": no such entry"
: "", 0, 0 );
- bsi->status = res;
+ bsi->bsi_status = res;
return BACKSQL_CONTINUE;
}
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error binding base id parameter\n", 0, 0, 0 );
- bsi->status = LDAP_OTHER;
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
break;
if ( !BACKSQL_SUCCESS( rc ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error executing query\n", 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, bsi->dbh, sth, rc );
+ backsql_PrintErrors( bi->db_env, bsi->bsi_dbh, sth, rc );
SQLFreeStmt( sth, SQL_DROP );
- bsi->status = LDAP_OTHER;
+ bsi->bsi_status = LDAP_OTHER;
return BACKSQL_CONTINUE;
}
sizeof( backsql_entryID ) );
c_id->id = strtol( row.cols[ 0 ], NULL, 0 );
c_id->keyval = strtol( row.cols[ 1 ], NULL, 0 );
- c_id->oc_id = bsi->oc->id;
+ c_id->oc_id = bsi->bsi_oc->id;
ber_str2bv( row.cols[ 3 ], 0, 1, &c_id->dn );
- c_id->next = bsi->id_list;
- bsi->id_list = c_id;
- bsi->n_candidates--;
+ c_id->next = bsi->bsi_id_list;
+ bsi->bsi_id_list = c_id;
+ bsi->bsi_n_candidates--;
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"added entry id=%ld, keyval=%ld dn='%s'\n",
c_id->id, c_id->keyval, row.cols[ 3 ] );
- if ( bsi->n_candidates == -1 ) {
+ if ( bsi->bsi_n_candidates == -1 ) {
break;
}
}
SQLFreeStmt( sth, SQL_DROP );
Debug( LDAP_DEBUG_TRACE, "<==backsql_oc_get_candidates(): %d\n",
- n_candidates - bsi->n_candidates, 0, 0 );
+ n_candidates - bsi->bsi_n_candidates, 0, 0 );
- return ( bsi->n_candidates == -1 ? BACKSQL_STOP : BACKSQL_CONTINUE );
+ return ( bsi->bsi_n_candidates == -1 ? BACKSQL_STOP : BACKSQL_CONTINUE );
}
int
* of entries matching LDAP query filter and scope (or at least
* candidates), and get the IDs
*/
- srch_info.n_candidates = ( isroot ? -2 : limit->lms_s_unchecked == -1
+ srch_info.bsi_n_candidates = ( isroot ? -2 : limit->lms_s_unchecked == -1
? -2 : limit->lms_s_unchecked );
avl_apply( bi->oc_by_oc, backsql_oc_get_candidates,
&srch_info, BACKSQL_STOP, AVL_INORDER );
if ( !isroot && limit->lms_s_unchecked != -1 ) {
- if ( srch_info.n_candidates == -1 ) {
+ if ( srch_info.bsi_n_candidates == -1 ) {
rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
send_ldap_result( op, rs );
goto done;
* mentioned in attrs and filter), test it against full filter
* and then send to client
*/
- for ( eid = srch_info.id_list; eid != NULL;
+ for ( eid = srch_info.bsi_id_list; eid != NULL;
eid = backsql_free_entryID( eid, 1 ) ) {
Attribute *hasSubordinate = NULL,
*a = NULL;
rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS
: LDAP_REFERRAL;
} else {
- rs->sr_err = srch_info.status;
+ rs->sr_err = srch_info.bsi_status;
}
send_ldap_result( op, rs );
}
done:;
- ch_free( srch_info.attrs );
+ ch_free( srch_info.bsi_attrs );
Debug( LDAP_DEBUG_TRACE, "<==backsql_search()\n", 0, 0, 0 );
return 0;