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>
31 wt_compare( Operation *op, SlapReply *rs )
33 struct wt_info *wi = (struct wt_info *) op->o_bd->be_private;
35 int manageDSAit = get_manageDSAit( op );
39 Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(wt_compare) ": %s\n",
40 op->o_req_dn.bv_val, 0, 0 );
42 wc = wt_ctx_get(op, wi);
44 Debug( LDAP_DEBUG_ANY,
45 LDAP_XSTRING(wt_compare)
46 ": wt_ctx_get failed\n",
48 rs->sr_err = LDAP_OTHER;
49 rs->sr_text = "internal error";
50 send_ldap_result( op, rs );
54 rs->sr_err = wt_dn2entry(op->o_bd, wc, &op->o_req_ndn, &e);
55 switch( rs->sr_err ) {
60 rs->sr_err = LDAP_OTHER;
61 rs->sr_text = "internal error";
65 if ( rs->sr_err == WT_NOTFOUND ) {
67 /* return referral only if "disclose" is granted on the object */
68 if ( ! access_allowed( op, e, slap_schema.si_ad_entry,
69 NULL, ACL_DISCLOSE, NULL ) )
71 rs->sr_err = LDAP_NO_SUCH_OBJECT;
73 rs->sr_matched = ch_strdup( e->e_dn );
74 if ( is_entry_referral( e )) {
75 BerVarray ref = get_entry_referrals( op, e );
76 rs->sr_ref = referral_rewrite( ref,
80 ber_bvarray_free( ref );
84 rs->sr_err = LDAP_REFERRAL;
89 rs->sr_ref = referral_rewrite( default_referral,
93 rs->sr_err = rs->sr_ref ? LDAP_REFERRAL : LDAP_NO_SUCH_OBJECT;
96 rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
97 send_ldap_result( op, rs );
101 if (!manageDSAit && is_entry_referral( e ) ) {
102 /* return referral only if "disclose" is granted on the object */
103 if ( !access_allowed( op, e, slap_schema.si_ad_entry,
104 NULL, ACL_DISCLOSE, NULL ) )
106 rs->sr_err = LDAP_NO_SUCH_OBJECT;
108 /* entry is a referral, don't allow compare */
109 rs->sr_ref = get_entry_referrals( op, e );
110 rs->sr_err = LDAP_REFERRAL;
111 rs->sr_matched = e->e_name.bv_val;
114 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, 0, 0 );
116 send_ldap_result( op, rs );
118 ber_bvarray_free( rs->sr_ref );
120 rs->sr_matched = NULL;
124 rs->sr_err = slap_compare_entry( op, e, op->orc_ava );
127 send_ldap_result( op, rs );
129 switch ( rs->sr_err ) {
130 case LDAP_COMPARE_FALSE:
131 case LDAP_COMPARE_TRUE:
132 rs->sr_err = LDAP_SUCCESS;
138 wt_entry_return( e );
145 * indent-tabs-mode: t