backsql_init_search( &bsi, &dn, LDAP_SCOPE_BASE,
-1, -1, -1, NULL, dbh, op, rs, anlist );
- e = backsql_id2entry( &bsi, &user_entry, &user_id );
- if ( e == NULL ) {
+ bsi.bsi_e = &user_entry;
+ rc = backsql_id2entry( &bsi, &user_id );
+ if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
- "error in backsql_id2entry() - auth failed\n",
- 0, 0, 0 );
- rs->sr_err = LDAP_OTHER;
+ "error %d in backsql_id2entry() "
+ "- auth failed\n", rc, 0, 0 );
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
goto error_return;
}
+ e = &user_entry;
if ( ! access_allowed( op, e, password, NULL, ACL_AUTH, NULL ) ) {
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
goto error_return;
}
- if ( ( a = attr_find( e->e_attrs, password ) ) == NULL ) {
+ a = attr_find( e->e_attrs, password );
+ if ( a == NULL ) {
rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
goto error_return;
}
}
user_entry.e_attrs = nrs.sr_operational_attrs;
- e = &user_entry;
} else {
backsql_init_search( &bsi, &dn, LDAP_SCOPE_BASE,
-1, -1, -1, NULL, dbh, op, rs, anlist );
- e = backsql_id2entry( &bsi, &user_entry, &user_id );
- if ( e == NULL ) {
+ bsi.bsi_e = &user_entry;
+ rc = backsql_id2entry( &bsi, &user_id );
+ if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
- "error in backsql_id2entry() "
- "- compare failed\n", 0, 0, 0 );
- rs->sr_err = LDAP_OTHER;
+ "error %d in backsql_id2entry() "
+ "- compare failed\n", rc, 0, 0 );
+ rs->sr_err = rc;
goto return_results;
}
}
+ e = &user_entry;
if ( ! access_allowed( op, e, op->oq_compare.rs_ava->aa_desc,
&op->oq_compare.rs_ava->aa_value,
}
if ( e != NULL ) {
- if ( e->e_name.bv_val != NULL ) {
- free( e->e_name.bv_val );
- }
-
- if ( e->e_nname.bv_val != NULL ) {
- free( e->e_nname.bv_val );
- }
-
- if ( e->e_attrs != NULL ) {
- attrs_free( e->e_attrs );
- }
+ entry_clean( e );
}
Debug(LDAP_DEBUG_TRACE,"<==backsql_compare()\n",0,0,0);
return 1;
}
-Entry *
-backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid )
+int
+backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid )
{
int i;
int rc;
Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 );
- rc = dnPrettyNormal( NULL, &eid->eid_dn, &e->e_name, &e->e_nname,
+ assert( bsi->bsi_e );
+
+ memset( bsi->bsi_e, 0, sizeof( Entry ) );
+
+ rc = dnPrettyNormal( NULL, &eid->eid_dn,
+ &bsi->bsi_e->e_name, &bsi->bsi_e->e_nname,
bsi->bsi_op->o_tmpmemctx );
if ( rc != LDAP_SUCCESS ) {
- return NULL;
+ return rc;
}
+ bsi->bsi_e->e_attrs = NULL;
+ bsi->bsi_e->e_private = NULL;
+
bsi->bsi_oc = backsql_id2oc( bsi->bsi_op->o_bd->be_private,
eid->eid_oc_id );
- bsi->bsi_e = e;
bsi->bsi_c_eid = eid;
- e->e_attrs = NULL;
- e->e_private = NULL;
#ifndef BACKSQL_ARBITRARY_KEY
- e->e_id = eid->eid_id;
+ bsi->bsi_e->e_id = eid->eid_id;
#endif /* ! BACKSQL_ARBITRARY_KEY */
+ rc = attr_merge_normalize_one( bsi->bsi_e, ad_oc,
+ &bsi->bsi_oc->bom_oc->soc_cname,
+ bsi->bsi_op->o_tmpmemctx );
+ if ( rc != LDAP_SUCCESS ) {
+ entry_clean( bsi->bsi_e );
+ return rc;
+ }
+
if ( bsi->bsi_attrs != NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
"custom attribute list\n", 0, 0, 0 );
for ( i = 0; bsi->bsi_attrs[ i ].an_name.bv_val; i++ ) {
backsql_at_map_rec **vat;
- AttributeName *attr = &bsi->bsi_attrs[ i ];
+ AttributeName *an = &bsi->bsi_attrs[ i ];
int j;
- if ( attr->an_desc == ad_oc ) {
- continue;
- }
-
/* if one of the attributes listed here is
* a subtype of another, it must be ignored,
* because subtypes are already dealt with
}
/* skip subtypes */
- if ( is_at_subtype( attr->an_desc->ad_type, bsi->bsi_attrs[ j ].an_desc->ad_type ) )
+ if ( is_at_subtype( an->an_desc->ad_type,
+ bsi->bsi_attrs[ j ].an_desc->ad_type ) )
{
goto next;
}
}
- rc = backsql_supad2at( bsi->bsi_oc, attr->an_desc, &vat );
+ rc = backsql_supad2at( bsi->bsi_oc, an->an_desc, &vat );
if ( rc != 0 || vat == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
"attribute \"%s\" is not defined "
"for objectlass \"%s\"\n",
- attr->an_name.bv_val,
+ an->an_name.bv_val,
BACKSQL_OC_NAME( bsi->bsi_oc ), 0 );
continue;
}
bsi, 0, AVL_INORDER );
}
- if ( attr_merge_normalize_one( bsi->bsi_e, ad_oc,
- &bsi->bsi_oc->bom_oc->soc_cname,
- bsi->bsi_op->o_tmpmemctx ) ) {
- entry_free( e );
- return NULL;
- }
-
if ( global_schemacheck ) {
const char *text = NULL;
char textbuf[ 1024 ];
rc = structural_class( bv, &soc, NULL,
&text, textbuf, textlen );
if ( rc != LDAP_SUCCESS ) {
- entry_free( e );
- return NULL;
+ Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): "
+ "structural_class() failed %d (%s)\n",
+ bsi->bsi_e->e_name.bv_val,
+ rc, text ? text : "" );
+ entry_clean( bsi->bsi_e );
+ return rc;
}
if ( ( bsi->bsi_flags | BSQL_SF_ALL_OPER )
slap_schema.si_ad_structuralObjectClass,
&soc, bsi->bsi_op->o_tmpmemctx );
if ( rc != LDAP_SUCCESS ) {
- entry_free( e );
- return NULL;
+ entry_clean( bsi->bsi_e );
+ return rc;
}
}
}
Debug( LDAP_DEBUG_TRACE, "<==backsql_id2entry()\n", 0, 0, 0 );
- return e;
+ return LDAP_SUCCESS;
}
#endif /* SLAPD_SQL */
backsql_entryID *backsql_free_entryID( backsql_entryID *id, int freeit );
/* turns an ID into an entry */
-Entry *backsql_id2entry( backsql_srch_info *bsi, Entry *e,
- backsql_entryID *id );
+int backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *id );
/*
* schema-map.c
oc_map_id integer unsigned not null references ldap_oc_mappings(id),
name varchar(255) not null,
sel_expr varchar(255) not null,
+ sel_expr_u varchar(255),
from_tbls varchar(255) not null,
join_where varchar(255),
add_proc varchar(255),
-insert into institutes (id,name) values (1,'sql');
+insert into institutes (id,name) values (1,'Example');
insert into persons (id,name) values (1,'Mitya Kovalev');
insert into persons (id,name) values (2,'Torvlobnor Puzdoy');
values (7,3,'o','institutes.name','institutes',NULL,NULL,NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (8,1,'documentDN','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
- 'ldap_entries.keyval=documents.id AND ldap_entries.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+values (8,1,'documentIdentifier','documentIdentifier.dn','ldap_entries AS documentIdentifier,documents,authors_docs,persons',
+ 'documentIdentifier.keyval=documents.id AND documentIdentifier.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
NULL,NULL,3,0);
-- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
-- parent the "ldap_entries.id" of the parent of this objectClass; 0 if it is the "suffix" of the database
-- keyval the value of the "keytbl.keycol" defined for this objectClass
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (1,'o=sql,c=RU',3,0,1);
+values (1,'o=Example,c=RU',3,0,1);
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (2,'cn=Mitya Kovalev,o=sql,c=RU',1,1,1);
+values (2,'cn=Mitya Kovalev,o=Example,c=RU',1,1,1);
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (3,'cn=Torvlobnor Puzdoy,o=sql,c=RU',1,1,2);
+values (3,'cn=Torvlobnor Puzdoy,o=Example,c=RU',1,1,2);
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (4,'cn=Akakiy Zinberstein,o=sql,c=RU',1,1,3);
+values (4,'cn=Akakiy Zinberstein,o=Example,c=RU',1,1,3);
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (5,'documentTitle=book1,o=sql,c=RU',2,1,1);
+values (5,'documentTitle=book1,o=Example,c=RU',2,1,1);
insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
-values (6,'documentTitle=book2,o=sql,c=RU',2,1,2);
+values (6,'documentTitle=book2,o=Example,c=RU',2,1,2);
-- objectClass mapping: entries that have multiple objectClass instances are listed here with the objectClass name (view them as auxiliary objectClass)
-- entry_id the "ldap_entries.id" of the entry that should be treated as a referral
-- url the URI of the referral
insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost');
+values (4,'ldap://localhost/');
+
{
backsql_at_map_rec *at_map;
char s[] = "+9223372036854775807L";
- ber_len_t slen;
+ struct berval sbv;
struct berbuf bb;
-
+ sbv.bv_val = s;
snprintf( s, sizeof( s ), "%ld", oc_map->bom_id );
- slen = strlen( s );
+ sbv.bv_len = strlen( s );
+ /* extra objectClasses */
at_map = (backsql_at_map_rec *)ch_calloc(1,
sizeof( backsql_at_map_rec ) );
at_map->bam_ad = slap_schema.si_ad_objectClass;
bb.bb_val.bv_val = NULL;
bb.bb_val.bv_len = 0;
bb.bb_len = 0;
- backsql_strfcat( &bb, "lbcbll",
+ backsql_strfcat( &bb, "lbcblb",
(ber_len_t)STRLENOF( "ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entries.keyval=" ),
"ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entries.keyval=",
&oc_map->bom_keytbl,
&oc_map->bom_keycol,
(ber_len_t)STRLENOF( " and ldap_entries.oc_map_id=" ),
" and ldap_entries.oc_map_id=",
- slen, s );
+ &sbv );
at_map->bam_oc = oc_map->bom_oc;
at_map->bam_join_where = bb.bb_val;
oc_map->bom_oc->soc_cname.bv_val, 0 );
}
+ /* referral attribute */
at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) );
at_map->bam_ad = slap_schema.si_ad_ref;
ber_str2bv( "ldap_referrals.url", 0, 1, &at_map->bam_sel_expr );
ber_str2bv( "ldap_referrals,ldap_entries", 0, 1, &at_map->bam_from_tbls );
-
- bb.bb_val.bv_val = NULL;
- bb.bb_val.bv_len = 0;
+
bb.bb_len = at_map->bam_from_tbls.bv_len + 1;
+ bb.bb_val = at_map->bam_from_tbls;
backsql_merge_from_clause( &bb, &oc_map->bom_keytbl );
at_map->bam_from_tbls = bb.bb_val;
bb.bb_val.bv_val = NULL;
bb.bb_val.bv_len = 0;
bb.bb_len = 0;
- backsql_strfcat( &bb, "lbcbll",
+ backsql_strfcat( &bb, "lbcblb",
(ber_len_t)STRLENOF( "ldap_entries.id=ldap_referrals.entry_id and ldap_entries.keyval=" ),
"ldap_entries.id=ldap_referrals.entry_id and ldap_entries.keyval=",
&oc_map->bom_keytbl,
&oc_map->bom_keycol,
(ber_len_t)STRLENOF( " and ldap_entries.oc_map_id=" ),
" and ldap_entries.oc_map_id=",
- slen, s );
+ &sbv );
at_map->bam_oc = NULL;
at_map->bam_join_where = bb.bb_val;
return 1;
}
- for ( ; bsi->bsi_attrs[ n_attrs ].an_name.bv_val; n_attrs++ ) {
+ for ( ; !BER_BVISNULL( &bsi->bsi_attrs[ n_attrs ].an_name ); n_attrs++ ) {
an = &bsi->bsi_attrs[ n_attrs ];
Debug( LDAP_DEBUG_TRACE, "==>backsql_attrlist_add(): "
an[ n_attrs ].an_name = ad->ad_cname;
an[ n_attrs ].an_desc = ad;
- an[ n_attrs + 1 ].an_name.bv_val = NULL;
- an[ n_attrs + 1 ].an_name.bv_len = 0;
+ BER_BVZERO( &an[ n_attrs + 1 ].an_name );
bsi->bsi_attrs = an;
} else {
bsi->bsi_attrs = (AttributeName *)ch_calloc( 1,
sizeof( AttributeName ) );
- bsi->bsi_attrs[ 0 ].an_name.bv_val = NULL;
- bsi->bsi_attrs[ 0 ].an_name.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_attrs[ 0 ].an_name );
- for ( p = attrs; p->an_name.bv_val; p++ ) {
+ for ( p = attrs; !BER_BVISNULL( &p->an_name ); p++ ) {
/*
* ignore "1.1"; handle "+"
*/
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;
+ BER_BVZERO( &bsi->bsi_sel.bb_val );
bsi->bsi_sel.bb_len = 0;
- bsi->bsi_from.bb_val.bv_val = NULL;
- bsi->bsi_from.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_from.bb_val );
bsi->bsi_from.bb_len = 0;
- bsi->bsi_join_where.bb_val.bv_val = NULL;
- bsi->bsi_join_where.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_join_where.bb_val );
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;
+ BER_BVZERO( &bsi->bsi_flt_where.bb_val );
bsi->bsi_flt_where.bb_len = 0;
bsi->bsi_filter_oc = NULL;
* val LIKE '%1%2%3%4%'
*/
- bv.bv_len = 0;
+ BER_BVZERO( &bv );
if ( f->f_sub_initial.bv_val ) {
bv.bv_len += f->f_sub_initial.bv_len;
}
bv.bv_val = ch_malloc( bv.bv_len + 1 );
s = 0;
- if ( f->f_sub_initial.bv_val ) {
+ if ( !BER_BVISNULL( &f->f_sub_initial ) ) {
bv.bv_val[ s ] = f->f_sub_initial.bv_val[ 0 ];
for ( i = 1; i < f->f_sub_initial.bv_len; i++ ) {
bv.bv_val[ s + 2 * i - 1 ] = '%';
}
if ( f->f_sub_any != NULL ) {
- for ( a = 0; f->f_sub_any[ a ].bv_val != NULL; a++ ) {
+ for ( a = 0; !BER_BVISNULL( &f->f_sub_any[ a ] ); a++ ) {
bv.bv_val[ s ] = f->f_sub_any[ a ].bv_val[ 0 ];
for ( i = 1; i < f->f_sub_any[ a ].bv_len; i++ ) {
bv.bv_val[ s + 2 * i - 1 ] = '%';
}
}
- if ( f->f_sub_final.bv_val ) {
+ if ( !BER_BVISNULL( &f->f_sub_final ) ) {
bv.bv_val[ s ] = f->f_sub_final.bv_val[ 0 ];
for ( i = 1; i < f->f_sub_final.bv_len; i++ ) {
bv.bv_val[ s + 2 * i - 1 ] = '%';
(ber_len_t)STRLENOF( " LIKE '" ), " LIKE '" );
}
- if ( f->f_sub_initial.bv_val != NULL ) {
+ if ( !BER_BVISNULL( &f->f_sub_initial ) ) {
ber_len_t start;
#ifdef BACKSQL_TRACE
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++ ) {
+ for ( i = 0; !BER_BVISNULL( &f->f_sub_any[ i ] ); i++ ) {
ber_len_t start;
#ifdef BACKSQL_TRACE
}
}
- if ( f->f_sub_final.bv_val != NULL ) {
+ if ( !BER_BVISNULL( &f->f_sub_final ) ) {
ber_len_t start;
#ifdef BACKSQL_TRACE
*/
backsql_attrlist_add( bsi, at->bam_ad );
- if ( at->bam_join_where.bv_val != NULL
+ if ( !BER_BVISNULL( &at->bam_join_where )
&& strstr( bsi->bsi_join_where.bb_val.bv_val, at->bam_join_where.bv_val ) == NULL ) {
backsql_strfcat( &bsi->bsi_join_where, "lb",
(ber_len_t)STRLENOF( " AND " ), " AND ",
int rc;
assert( query );
- query->bv_val = NULL;
- query->bv_len = 0;
+ BER_BVZERO( query );
Debug( LDAP_DEBUG_TRACE, "==>backsql_srch_query()\n", 0, 0, 0 );
- bsi->bsi_sel.bb_val.bv_val = NULL;
- bsi->bsi_sel.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_sel.bb_val );
+ BER_BVZERO( &bsi->bsi_sel.bb_val );
bsi->bsi_sel.bb_len = 0;
- bsi->bsi_from.bb_val.bv_val = NULL;
- bsi->bsi_from.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_from.bb_val );
bsi->bsi_from.bb_len = 0;
- bsi->bsi_join_where.bb_val.bv_val = NULL;
- bsi->bsi_join_where.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_join_where.bb_val );
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;
+ BER_BVZERO( &bsi->bsi_flt_where.bb_val );
bsi->bsi_flt_where.bb_len = 0;
backsql_strfcat( &bsi->bsi_sel, "lbcbc",
&bsi->bsi_oc->bom_keycol,
',' );
- if ( bi->strcast_func.bv_val ) {
+ if ( !BER_BVISNULL( &bi->strcast_func ) ) {
backsql_strfcat( &bsi->bsi_sel, "blbl",
&bi->strcast_func,
(ber_len_t)sizeof( "('" /* ') */ ) - 1,
* anything. No need to issue the query
*/
free( query->bv_val );
- query->bv_val = NULL;
+ BER_BVZERO( query );
}
free( bsi->bsi_sel.bb_val.bv_val );
- bsi->bsi_sel.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_sel.bb_val );
bsi->bsi_sel.bb_len = 0;
free( bsi->bsi_from.bb_val.bv_val );
- bsi->bsi_from.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_from.bb_val );
bsi->bsi_from.bb_len = 0;
free( bsi->bsi_join_where.bb_val.bv_val );
- bsi->bsi_join_where.bb_val.bv_len = 0;
+ BER_BVZERO( &bsi->bsi_join_where.bb_val );
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;
+ BER_BVZERO( &bsi->bsi_flt_where.bb_val );
bsi->bsi_flt_where.bb_len = 0;
Debug( LDAP_DEBUG_TRACE, "<==backsql_srch_query() returns %s\n",
}
}
- if ( query.bv_val == NULL ) {
+ if ( BER_BVISNULL( &query ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"could not construct query for objectclass \"%s\"\n",
oc->bom_oc->soc_cname.bv_val, 0, 0 );
rc = backsql_Prepare( bsi->bsi_dbh, &sth, query.bv_val, 0 );
free( query.bv_val );
+ BER_BVZERO( &query );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
"error preparing query\n", 0, 0, 0 );
backsql_info *bi = (backsql_info *)op->o_bd->be_private;
SQLHDBC dbh;
int sres;
- Entry *entry, *res;
+ Entry user_entry = { 0 };
int manageDSAit;
time_t stoptime = 0;
backsql_srch_info srch_info;
* mentioned in attrs and filter), test it against full filter
* and then send to client
*/
- for ( eid = srch_info.bsi_id_list; eid != NULL;
- eid = backsql_free_entryID( eid, 1 ) ) {
+ for ( eid = srch_info.bsi_id_list;
+ eid != NULL;
+ eid = backsql_free_entryID( eid, 1 ) )
+ {
+ int rc;
Attribute *hasSubordinate = NULL,
*a = NULL;
eid->eid_id, eid->eid_oc_id, eid->eid_keyval );
#endif /* ! BACKSQL_ARBITRARY_KEY */
- entry = (Entry *)ch_calloc( sizeof( Entry ), 1 );
- res = backsql_id2entry( &srch_info, entry, eid );
- if ( res == NULL ) {
+ srch_info.bsi_e = &user_entry;
+ rc = backsql_id2entry( &srch_info, eid );
+ if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
- "error in backsql_id2entry() "
- "- skipping entry\n", 0, 0, 0 );
+ "error %d in backsql_id2entry() "
+ "- skipping\n", rc, 0, 0 );
continue;
}
if ( !manageDSAit &&
op->ors_scope != LDAP_SCOPE_BASE &&
op->ors_scope != BACKSQL_SCOPE_BASE_LIKE &&
- is_entry_referral( entry ) ) {
+ is_entry_referral( &user_entry ) )
+ {
BerVarray refs;
struct berval matched_dn;
- ber_dupbv( &matched_dn, &entry->e_name );
- refs = get_entry_referrals( op, entry );
+ ber_dupbv( &matched_dn, &user_entry.e_name );
+ refs = get_entry_referrals( op, &user_entry );
if ( refs ) {
rs->sr_ref = referral_rewrite( refs,
&matched_dn, &op->o_req_dn,
* filter_has_subordinates()
*/
if ( srch_info.bsi_flags & BSQL_SF_FILTER_HASSUBORDINATE ) {
- int rc;
-
- rc = backsql_has_children( bi, dbh, &entry->e_nname );
+ rc = backsql_has_children( bi, dbh, &user_entry.e_nname );
- switch( rc ) {
+ switch ( rc ) {
case LDAP_COMPARE_TRUE:
case LDAP_COMPARE_FALSE:
hasSubordinate = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
if ( hasSubordinate != NULL ) {
- for ( a = entry->e_attrs;
+ for ( a = user_entry.e_attrs;
a && a->a_next;
a = a->a_next );
}
}
- if ( test_filter( op, entry, op->ors_filter )
+ if ( test_filter( op, &user_entry, op->ors_filter )
== LDAP_COMPARE_TRUE ) {
if ( hasSubordinate && !( srch_info.bsi_flags & BSQL_SF_ALL_OPER )
&& !ad_inlist( slap_schema.si_ad_hasSubordinates, op->ors_attrs ) ) {
{
rs->sr_attrs = op->ors_attrs;
rs->sr_operational_attrs = NULL;
- rs->sr_entry = entry;
+ rs->sr_entry = &user_entry;
rs->sr_flags = REP_ENTRY_MODIFIABLE;
sres = send_search_entry( op, rs );
rs->sr_entry = NULL;
break;
}
}
- entry_free( entry );
+ entry_clean( &user_entry );
if ( op->ors_slimit != SLAP_NO_LIMIT
&& rs->sr_nentries >= op->ors_slimit )
}
end_of_search:;
+ /* in case we got here accidentally */
+ entry_clean( &user_entry );
if ( rs->sr_nentries > 0 ) {
rs->sr_ref = rs->sr_v2ref;
rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS
: LDAP_REFERRAL;
+
} else {
rs->sr_err = srch_info.bsi_status;
}
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "backsql_strcat(): "
- "new buflen=%d, dest=%p\n", dest->bb_len, dest, 0 );
+ "new buflen=%d, dest=%p\n",
+ dest->bb_len, dest, 0 );
#endif /* BACKSQL_TRACE */
}
AC_MEMCPY( dest->bb_val.bv_val + cdlen, cstr, cslen + 1 );
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "<==backsql_strcat() (dest=\"%s\")\n",
- dest, 0, 0 );
+ dest->bb_val.bv_val, 0, 0 );
#endif /* BACKSQL_TRACE */
dest->bb_val.bv_len = cdlen;
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "<==backsql_strfcat() (dest=\"%s\")\n",
- dest, 0, 0 );
+ dest->bb_val.bv_val, 0, 0 );
#endif /* BACKSQL_TRACE */
dest->bb_val.bv_len = cdlen;
#ifdef BACKSQL_TRACE
Debug( LDAP_DEBUG_TRACE, "==>backsql_merge_from_clause(): "
"dest_from=\"%s\",src_from=\"%s\"\n",
- dest_from ? dest_from->bb_val.bv_val : "<NULL>", src_from, 0 );
+ dest_from ? dest_from->bb_val.bv_val : "<NULL>",
+ src_from->bv_val, 0 );
#endif /* BACKSQL_TRACE */
srcc = ch_strdup( src_from->bv_val );