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"
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 )
46 cache_return_entry_r( &li->li_cache, matched );
48 refs = default_referral;
51 send_ldap_result( conn, op, LDAP_REFERRAL,
52 matched_dn, NULL, refs, NULL );
54 if( matched != 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,
67 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
70 send_ldap_result( conn, op, LDAP_REFERRAL,
71 e->e_dn, NULL, refs, NULL );
79 if ( ! access_allowed( be, conn, op, e,
80 ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
82 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
83 NULL, NULL, NULL, NULL );
88 if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
89 send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE,
90 NULL, NULL, NULL, NULL );
95 #ifdef SLAPD_SCHEMA_COMPAT
96 if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
97 send_ldap_result( conn, op, LDAP_COMPARE_TRUE,
98 NULL, NULL, NULL, NULL );
101 send_ldap_result( conn, op, LDAP_COMPARE_FALSE,
102 NULL, NULL, NULL, NULL );
107 cache_return_entry_r( &li->li_cache, e );