int
backsql_compare( Operation *op, SlapReply *rs )
{
- backsql_info *bi = (backsql_info*)op->o_bd->be_private;
- backsql_entryID user_id = BACKSQL_ENTRYID_INIT;
SQLHDBC dbh;
Entry *e = NULL, user_entry;
Attribute *a = NULL;
backsql_srch_info bsi;
int rc;
AttributeName anlist[2];
- struct berval dn;
+ struct berval ndn;
user_entry.e_name.bv_val = NULL;
user_entry.e_name.bv_len = 0;
goto return_results;
}
- dn = op->o_req_dn;
- if ( backsql_api_dn2odbc( op, rs, &dn ) ) {
+ ndn = op->o_req_ndn;
+ if ( backsql_api_dn2odbc( op, rs, &ndn ) ) {
Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
"backsql_api_dn2odbc failed\n",
0, 0, 0 );
goto return_results;
}
- rc = backsql_dn2id( bi, &user_id, dbh, &dn );
- if ( rc != LDAP_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
- "could not retrieve compare dn id - no such entry\n",
- 0, 0, 0 );
- rs->sr_err = LDAP_NO_SUCH_OBJECT;
- goto return_results;
- }
-
memset( &anlist[0], 0, 2 * sizeof( AttributeName ) );
anlist[0].an_name = op->oq_compare.rs_ava->aa_desc->ad_cname;
anlist[0].an_desc = op->oq_compare.rs_ava->aa_desc;
nrs.sr_attrs = anlist;
nrs.sr_entry = &user_entry;
- nrs.sr_opattrs = SLAP_OPATTRS_NO;
+ nrs.sr_attr_flags = SLAP_OPATTRS_NO;
nrs.sr_operational_attrs = NULL;
rs->sr_err = backsql_operational( op, &nrs );
}
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 ) {
+ rc = backsql_init_search( &bsi, &ndn, LDAP_SCOPE_BASE,
+ -1, -1, -1, NULL, dbh, op, rs, anlist, 1 );
+ if ( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
+ "could not retrieve compareDN ID - no such entry\n",
+ 0, 0, 0 );
+ rs->sr_err = LDAP_NO_SUCH_OBJECT;
+ goto return_results;
+ }
+
+ bsi.bsi_e = &user_entry;
+ rc = backsql_id2entry( &bsi, &bsi.bsi_base_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,
return_results:;
send_ldap_result( op, rs );
- if ( dn.bv_val != op->o_req_dn.bv_val ) {
- ch_free( dn.bv_val );
+ if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
+ (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
}
- 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 ( ndn.bv_val != op->o_req_ndn.bv_val ) {
+ ch_free( ndn.bv_val );
+ }
- if ( e->e_attrs != NULL ) {
- attrs_free( e->e_attrs );
- }
+ if ( e != NULL ) {
+ entry_clean( e );
}
Debug(LDAP_DEBUG_TRACE,"<==backsql_compare()\n",0,0,0);