1 /* OpenLDAP WiredTiger backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2017 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>.
17 * This work was developed by HAMANO Tsukasa <hamano@osstech.co.jp>
18 * based on back-bdb for inclusion in OpenLDAP Software.
19 * WiredTiger is a product of MongoDB Inc.
25 #include <ac/string.h>
30 * dn2entry - look up dn in the db and return the corresponding entry.
31 * No longer return closest ancestor, see wt_dn2pentry().
33 int wt_dn2entry( BackendDB *be,
38 WT_CURSOR *cursor = NULL;
44 WT_SESSION *session = wc->session;
46 if( ndn->bv_len == 0 ){
47 /* parent of root dn */
51 rc = session->open_cursor(session,
52 WT_INDEX_DN"(id, entry)",
55 Debug( LDAP_DEBUG_ANY,
56 LDAP_XSTRING(wt_dn2entry)
57 ": open_cursor failed: %s (%d)\n",
58 wiredtiger_strerror(rc), rc, 0 );
62 cursor->set_key(cursor, ndn->bv_val);
63 rc = cursor->search(cursor);
70 Debug( LDAP_DEBUG_ANY,
71 LDAP_XSTRING(wt_dn2entry)
72 ": search failed: %s (%d)\n",
73 wiredtiger_strerror(rc), rc, 0 );
76 cursor->get_value(cursor, &id, &item);
77 rc = wt_entry_header( &item, &eh );
79 eoff = eh.data - (char *)item.data;
80 eh.bv.bv_len = eh.nvals * sizeof( struct berval ) + item.size;
81 eh.bv.bv_val = ch_malloc( eh.bv.bv_len );
82 memset(eh.bv.bv_val, 0xff, eh.bv.bv_len);
83 eh.data = eh.bv.bv_val + eh.nvals * sizeof( struct berval );
84 memcpy(eh.data, item.data, item.size);
86 rc = entry_decode( &eh, &e );
88 Debug( LDAP_DEBUG_ANY,
89 LDAP_XSTRING(wt_dn2entry)
90 ": entry decode error: %s (%d)\n",
100 cursor->close(cursor);
105 /* dn2pentry - return parent entry */
106 int wt_dn2pentry( BackendDB *be,
114 if (be_issuffix( be, ndn )) {
119 dnParent( ndn, &pdn );
120 rc = wt_dn2entry(be, wc, &pdn, &e);
127 * indent-tabs-mode: t