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, &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,
45 dn, LDAP_SCOPE_DEFAULT )
47 cache_return_entry_r( &li->li_cache, matched );
49 refs = referral_rewrite( default_referral,
50 NULL, dn, LDAP_SCOPE_DEFAULT );
53 send_ldap_result( conn, op, LDAP_REFERRAL,
54 matched_dn, NULL, refs, NULL );
62 if (!manageDSAit && is_entry_referral( e ) ) {
63 /* entry is a referral, don't allow add */
64 struct berval **refs = get_entry_referrals( be,
65 conn, op, e, dn, LDAP_SCOPE_DEFAULT );
68 LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
69 "ldbm_back_compare: entry (%s) is a referral.\n", e->e_dn ));
71 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
76 send_ldap_result( conn, op, LDAP_REFERRAL,
77 e->e_dn, NULL, refs, NULL );
85 if ( ! access_allowed( be, conn, op, e,
86 ava->aa_desc, ava->aa_value, ACL_COMPARE ) )
88 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
89 NULL, NULL, NULL, NULL );
94 rc = LDAP_NO_SUCH_ATTRIBUTE;
96 for(a = attrs_find( e->e_attrs, ava->aa_desc );
98 a = attrs_find( a->a_next, ava->aa_desc ))
100 rc = LDAP_COMPARE_FALSE;
102 if ( value_find_ex( ava->aa_desc,
103 SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
104 a->a_vals, ava->aa_value ) == 0 )
106 rc = LDAP_COMPARE_TRUE;
112 send_ldap_result( conn, op, rc,
113 NULL, NULL, NULL, NULL );
115 if( rc != LDAP_NO_SUCH_ATTRIBUTE ) {
121 cache_return_entry_r( &li->li_cache, e );