1 /* compare.c - bdb backend compare routine */
4 * Copyright 1998-2000 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( 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,
55 dn, LDAP_SCOPE_DEFAULT )
57 bdb_entry_return( be, matched );
61 refs = referral_rewrite( default_referral,
62 NULL, dn, LDAP_SCOPE_DEFAULT );
65 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
66 matched_dn, NULL, refs, NULL );
74 if (!manageDSAit && is_entry_referral( e ) ) {
75 /* entry is a referral, don't allow add */
76 struct berval **refs = get_entry_referrals( be,
77 conn, op, e, dn, LDAP_SCOPE_DEFAULT );
79 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
82 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
83 e->e_dn, NULL, refs, NULL );
89 if ( ! access_allowed( be, conn, op, e,
90 ava->aa_desc, ava->aa_value, ACL_COMPARE ) )
92 rc = LDAP_INSUFFICIENT_ACCESS;
96 rc = LDAP_NO_SUCH_ATTRIBUTE;
98 for(a = attrs_find( e->e_attrs, ava->aa_desc );
100 a = attrs_find( a->a_next, ava->aa_desc ))
102 rc = LDAP_COMPARE_FALSE;
104 if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
105 rc = LDAP_COMPARE_TRUE;
111 if( rc != LDAP_NO_SUCH_ATTRIBUTE ) {
117 send_ldap_result( conn, op, LDAP_SUCCESS,
118 NULL, text, NULL, NULL );
123 bdb_entry_return( be, e );