1 /* compare.c - bdb backend compare routine */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
23 AttributeAssertion *ava
26 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
31 const char *text = NULL;
32 int manageDSAit = get_manageDSAit( op );
35 rc = bdb_dn2entry_r( be, NULL, ndn, &e, &matched, 0 );
43 text = "internal error";
48 char *matched_dn = NULL;
51 if ( matched != NULL ) {
52 matched_dn = ch_strdup( matched->e_dn );
53 refs = is_entry_referral( matched )
54 ? get_entry_referrals( be, conn, op, matched )
56 bdb_cache_return_entry_r( &bdb->bi_cache, matched );
60 refs = referral_rewrite( default_referral,
61 NULL, dn, LDAP_SCOPE_DEFAULT );
64 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
65 matched_dn, NULL, refs, NULL );
67 ber_bvarray_free( refs );
73 if (!manageDSAit && is_entry_referral( e ) ) {
74 /* entry is a referral, don't allow add */
75 BerVarray refs = get_entry_referrals( be,
78 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
81 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
82 e->e_dn, NULL, refs, NULL );
84 ber_bvarray_free( refs );
88 if ( ! access_allowed( be, conn, op, e,
89 ava->aa_desc, &ava->aa_value, ACL_COMPARE ) )
91 rc = LDAP_INSUFFICIENT_ACCESS;
95 rc = LDAP_NO_SUCH_ATTRIBUTE;
97 for(a = attrs_find( e->e_attrs, ava->aa_desc );
99 a = attrs_find( a->a_next, ava->aa_desc ))
101 rc = LDAP_COMPARE_FALSE;
103 if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
104 rc = LDAP_COMPARE_TRUE;
110 if( rc != LDAP_NO_SUCH_ATTRIBUTE ) {
116 send_ldap_result( conn, op, LDAP_SUCCESS,
117 NULL, text, NULL, NULL );
122 bdb_cache_return_entry_r( &bdb->bi_cache, e );