1 /* compare.c - ldbm backend compare routine */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/socket.h>
12 #include <ac/string.h>
15 #include "back-ldbm.h"
16 #include "proto-back-ldbm.h"
27 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
32 int manageDSAit = get_manageDSAit( op );
34 /* get entry with reader lock */
35 if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
36 char *matched_dn = NULL;
37 struct berval **refs = NULL;
39 if ( matched != NULL ) {
40 matched_dn = ch_strdup( matched->e_dn );
41 refs = is_entry_referral( matched )
42 ? get_entry_referrals( be, conn, op, matched )
44 cache_return_entry_r( &li->li_cache, matched );
46 refs = default_referral;
49 send_ldap_result( conn, op, LDAP_REFERRAL,
50 matched_dn, NULL, refs, NULL );
52 if( matched != NULL ) {
60 if (!manageDSAit && is_entry_referral( e ) ) {
61 /* entry is a referral, don't allow add */
62 struct berval **refs = get_entry_referrals( be,
65 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
68 send_ldap_result( conn, op, LDAP_REFERRAL,
69 e->e_dn, NULL, refs, NULL );
77 if ( ! access_allowed( be, conn, op, e,
78 ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
80 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
81 NULL, NULL, NULL, NULL );
86 if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
87 send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE,
88 NULL, NULL, NULL, NULL );
93 if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
94 send_ldap_result( conn, op, LDAP_COMPARE_TRUE,
95 NULL, NULL, NULL, NULL );
97 send_ldap_result( conn, op, LDAP_COMPARE_FALSE,
98 NULL, NULL, NULL, NULL );
103 cache_return_entry_r( &li->li_cache, e );