mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-18 18:18:06 -05:00
Need both norm and non-norm match from dn2id
This commit is contained in:
parent
9c671db81b
commit
da7b9e2ea5
6 changed files with 28 additions and 13 deletions
|
|
@ -37,14 +37,14 @@ mdb_dn2entry(
|
|||
{
|
||||
int rc, rc2;
|
||||
ID id = NOID;
|
||||
struct berval bvm;
|
||||
struct berval mbv, nmbv;
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE, "mdb_dn2entry(\"%s\")\n",
|
||||
dn->bv_val, 0, 0 );
|
||||
|
||||
*e = NULL;
|
||||
|
||||
rc = mdb_dn2id( op, tid, dn, &id, &bvm );
|
||||
rc = mdb_dn2id( op, tid, dn, &id, &mbv, &nmbv );
|
||||
if ( rc ) {
|
||||
if ( matched )
|
||||
rc2 = mdb_id2entry( op, tid, id, e );
|
||||
|
|
@ -53,9 +53,11 @@ mdb_dn2entry(
|
|||
rc = mdb_id2entry( op, tid, id, e );
|
||||
}
|
||||
if ( *e ) {
|
||||
(*e)->e_name = bvm;
|
||||
(*e)->e_name = mbv;
|
||||
if ( rc == MDB_SUCCESS )
|
||||
ber_dupbv_x( &(*e)->e_nname, dn, op->o_tmpmemctx );
|
||||
else
|
||||
ber_dupbv_x( &(*e)->e_nname, &nmbv, op->o_tmpmemctx );
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
|
|
|||
|
|
@ -259,7 +259,8 @@ mdb_dn2id(
|
|||
MDB_txn *txn,
|
||||
struct berval *in,
|
||||
ID *id,
|
||||
struct berval *matched )
|
||||
struct berval *matched,
|
||||
struct berval *nmatched )
|
||||
{
|
||||
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
|
||||
MDB_cursor *cursor;
|
||||
|
|
@ -287,6 +288,10 @@ mdb_dn2id(
|
|||
matched->bv_len = 0;
|
||||
*matched->bv_val-- = '\0';
|
||||
}
|
||||
if ( nmatched ) {
|
||||
nmatched->bv_len = 0;
|
||||
nmatched->bv_val = 0;
|
||||
}
|
||||
|
||||
nrlen = tmp.bv_len - op->o_bd->be_nsuffix[0].bv_len;
|
||||
tmp.bv_val += nrlen;
|
||||
|
|
@ -328,6 +333,10 @@ mdb_dn2id(
|
|||
matched->bv_len++;
|
||||
}
|
||||
}
|
||||
if ( nmatched ) {
|
||||
nmatched->bv_val = tmp.bv_val;
|
||||
}
|
||||
|
||||
if ( tmp.bv_val > in->bv_val ) {
|
||||
for (ptr = tmp.bv_val - 2; ptr > in->bv_val &&
|
||||
!DN_SEPARATOR(*ptr); ptr--) /* empty */;
|
||||
|
|
@ -347,6 +356,9 @@ mdb_dn2id(
|
|||
strcpy( ptr, matched->bv_val );
|
||||
matched->bv_val = ptr;
|
||||
}
|
||||
if ( nmatched ) {
|
||||
nmatched->bv_len = in->bv_len - (nmatched->bv_val - in->bv_val);
|
||||
}
|
||||
|
||||
done:
|
||||
if( rc != 0 ) {
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ ext_candidates(
|
|||
MDB_IDL_ZERO( ids );
|
||||
if ( mra->ma_rule == slap_schema.si_mr_distinguishedNameMatch ) {
|
||||
base:
|
||||
rc = mdb_dn2id( op, rtxn, &mra->ma_value, &id, NULL );
|
||||
rc = mdb_dn2id( op, rtxn, &mra->ma_value, &id, NULL, NULL );
|
||||
if ( rc == MDB_SUCCESS ) {
|
||||
mdb_idl_insert( ids, id );
|
||||
}
|
||||
|
|
@ -690,7 +690,7 @@ equality_candidates(
|
|||
|
||||
if ( ava->aa_desc == slap_schema.si_ad_entryDN ) {
|
||||
ID id;
|
||||
rc = mdb_dn2id( op, rtxn, &ava->aa_value, &id, NULL );
|
||||
rc = mdb_dn2id( op, rtxn, &ava->aa_value, &id, NULL, NULL );
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
/* exactly one ID can match */
|
||||
ids[0] = 1;
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ txnReturn:
|
|||
new_ndn.bv_val, 0, 0 );
|
||||
|
||||
/* Shortcut the search */
|
||||
rs->sr_err = mdb_dn2id ( op, txn, &new_ndn, &nid, NULL );
|
||||
rs->sr_err = mdb_dn2id ( op, txn, &new_ndn, &nid, NULL, NULL );
|
||||
switch( rs->sr_err ) {
|
||||
case MDB_NOTFOUND:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -66,9 +66,10 @@ int mdb_dn2entry LDAP_P(( Operation *op, MDB_txn *tid,
|
|||
int mdb_dn2id(
|
||||
Operation *op,
|
||||
MDB_txn *txn,
|
||||
struct berval *dn,
|
||||
struct berval *ndn,
|
||||
ID *id,
|
||||
struct berval *matched );
|
||||
struct berval *matched,
|
||||
struct berval *nmatched );
|
||||
|
||||
int mdb_dn2id_add(
|
||||
Operation *op,
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ ID mdb_tool_dn2id_get(
|
|||
op.o_tmpmemctx = NULL;
|
||||
op.o_tmpmfuncs = &ch_mfuncs;
|
||||
|
||||
rc = mdb_dn2id( &op, txn, dn, &id, NULL );
|
||||
rc = mdb_dn2id( &op, txn, dn, &id, NULL, NULL );
|
||||
if ( rc == MDB_NOTFOUND )
|
||||
return NOID;
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ static int mdb_tool_next_id(
|
|||
{
|
||||
struct berval dn = e->e_name;
|
||||
struct berval ndn = e->e_nname;
|
||||
struct berval pdn, npdn, matched;
|
||||
struct berval pdn, npdn, nmatched;
|
||||
ID id, pid = 0;
|
||||
int rc;
|
||||
|
||||
|
|
@ -369,12 +369,12 @@ static int mdb_tool_next_id(
|
|||
return 0;
|
||||
}
|
||||
|
||||
rc = mdb_dn2id( op, tid, &ndn, &id, &matched );
|
||||
rc = mdb_dn2id( op, tid, &ndn, &id, NULL, &nmatched );
|
||||
if ( rc == MDB_NOTFOUND ) {
|
||||
if ( !be_issuffix( op->o_bd, &ndn ) ) {
|
||||
ID eid = e->e_id;
|
||||
dnParent( &ndn, &npdn );
|
||||
if ( matched.bv_len != npdn.bv_len ) {
|
||||
if ( nmatched.bv_len != npdn.bv_len ) {
|
||||
dnParent( &dn, &pdn );
|
||||
e->e_name = pdn;
|
||||
e->e_nname = npdn;
|
||||
|
|
|
|||
Loading…
Reference in a new issue