1 /* compare.c - ldbm backend compare routine */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
17 #include "proto-back-ldbm.h"
26 AttributeAssertion *ava
29 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
34 int manageDSAit = get_manageDSAit( op );
36 /* get entry with reader lock */
37 if ( (e = dn2entry_r( be, ndn->bv_val, &matched )) == NULL ) {
38 char *matched_dn = NULL;
39 struct berval **refs = NULL;
41 if ( matched != NULL ) {
42 matched_dn = ch_strdup( matched->e_dn );
43 refs = is_entry_referral( matched )
44 ? get_entry_referrals( be, conn, op, matched )
46 cache_return_entry_r( &li->li_cache, matched );
48 refs = referral_rewrite( default_referral,
49 NULL, dn, LDAP_SCOPE_DEFAULT );
52 send_ldap_result( conn, op, LDAP_REFERRAL,
53 matched_dn, NULL, refs, NULL );
61 if (!manageDSAit && is_entry_referral( e ) ) {
62 /* entry is a referral, don't allow add */
63 struct berval **refs = get_entry_referrals( be,
67 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
68 "ldbm_back_compare: entry (%s) is a referral.\n", e->e_dn ));
70 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
75 send_ldap_result( conn, op, LDAP_REFERRAL,
76 e->e_dn, NULL, refs, NULL );
84 if ( ! access_allowed( be, conn, op, e,
85 ava->aa_desc, &ava->aa_value, ACL_COMPARE ) )
87 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
88 NULL, NULL, NULL, NULL );
93 rc = LDAP_NO_SUCH_ATTRIBUTE;
95 for(a = attrs_find( e->e_attrs, ava->aa_desc );
97 a = attrs_find( a->a_next, ava->aa_desc ))
99 rc = LDAP_COMPARE_FALSE;
101 if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
102 rc = LDAP_COMPARE_TRUE;
108 send_ldap_result( conn, op, rc,
109 NULL, NULL, NULL, NULL );
111 if( rc != LDAP_NO_SUCH_ATTRIBUTE ) {
117 cache_return_entry_r( &li->li_cache, e );