]> git.sur5r.net Git - openldap/blob - servers/slapd/back-mdb/dn2entry.c
dn2id fixes, slapadd working
[openldap] / servers / slapd / back-mdb / dn2entry.c
1 /* dn2entry.c - routines to deal with the dn2id / id2entry glue */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2000-2011 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20 #include <ac/string.h>
21
22 #include "back-mdb.h"
23
24 /*
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.
28  */
29
30 int
31 mdb_dn2entry(
32         Operation *op,
33         MDB_txn *tid,
34         struct berval *dn,
35         Entry **e,
36         struct berval *matched )
37 {
38         int rc, rc2;
39         ID id;
40
41         Debug(LDAP_DEBUG_TRACE, "mdb_dn2entry(\"%s\")\n",
42                 dn->bv_val, 0, 0 );
43
44         *e = NULL;
45
46         rc = mdb_dn2id( op, tid, dn, &id, matched );
47         if ( rc ) {
48                 *e = NULL;
49         } else {
50                 rc = mdb_id2entry( op, tid, id, e );
51         }
52
53         return rc;
54 }