1 /* compare.c - ldbm backend compare routine */
4 * Copyright 1998-1999 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"
28 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
33 int manageDSAit = get_manageDSAit( op );
35 /* get entry with reader lock */
36 if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
37 char *matched_dn = NULL;
38 struct berval **refs = NULL;
40 if ( matched != NULL ) {
41 matched_dn = ch_strdup( matched->e_dn );
42 refs = is_entry_referral( matched )
43 ? get_entry_referrals( be, conn, op, matched )
45 cache_return_entry_r( &li->li_cache, matched );
47 refs = default_referral;
50 send_ldap_result( conn, op, LDAP_REFERRAL,
51 matched_dn, NULL, refs, NULL );
53 if( matched != 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,
66 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
69 send_ldap_result( conn, op, LDAP_REFERRAL,
70 e->e_dn, NULL, refs, NULL );
78 if ( ! access_allowed( be, conn, op, e,
79 ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
81 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
82 NULL, NULL, NULL, NULL );
87 if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
88 send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE,
89 NULL, NULL, NULL, NULL );
94 if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
95 send_ldap_result( conn, op, LDAP_COMPARE_TRUE,
96 NULL, NULL, NULL, NULL );
98 send_ldap_result( conn, op, LDAP_COMPARE_FALSE,
99 NULL, NULL, NULL, NULL );
104 cache_return_entry_r( &li->li_cache, e );