1 /* dn2entry.c - routines to deal with the dn2id / id2entry glue */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2013 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
25 * dn2entry - look up dn in the cache/indexes and return the corresponding
26 * entry. If the requested DN is not found and matched is TRUE, return info
27 * for the closest ancestor of the DN. Otherwise e is NULL.
39 struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
42 struct berval mbv, nmbv;
45 Debug(LDAP_DEBUG_TRACE, "mdb_dn2entry(\"%s\")\n",
46 dn->bv_val ? dn->bv_val : "", 0, 0 );
50 rc = mdb_dn2id( op, tid, m2, dn, &id, &mbv, &nmbv );
53 rc2 = mdb_cursor_open( tid, mdb->mi_id2entry, &mc );
54 if ( rc2 == MDB_SUCCESS ) {
55 rc2 = mdb_id2entry( op, mc, id, e );
56 mdb_cursor_close( mc );
61 rc = mdb_cursor_open( tid, mdb->mi_id2entry, &mc );
62 if ( rc == MDB_SUCCESS ) {
63 rc = mdb_id2entry( op, mc, id, e );
69 if ( rc == MDB_SUCCESS )
70 ber_dupbv_x( &(*e)->e_nname, dn, op->o_tmpmemctx );
72 ber_dupbv_x( &(*e)->e_nname, &nmbv, op->o_tmpmemctx );