1 /* compare.c - ldbm backend compare routine */
11 #include "back-ldbm.h"
12 #include "proto-back-ldbm.h"
23 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
28 int manageDSAit = get_manageDSAit( op );
30 /* get entry with reader lock */
31 if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
32 char *matched_dn = NULL;
33 struct berval **refs = NULL;
35 if ( matched != NULL ) {
36 matched_dn = ch_strdup( matched->e_dn );
37 refs = is_entry_referral( matched )
38 ? get_entry_referrals( be, conn, op, matched )
40 cache_return_entry_r( &li->li_cache, matched );
42 refs = default_referral;
45 send_ldap_result( conn, op, LDAP_REFERRAL,
46 matched_dn, NULL, refs, NULL );
48 if( matched != NULL ) {
56 if (!manageDSAit && is_entry_referral( e ) ) {
57 /* entry is a referral, don't allow add */
58 struct berval **refs = get_entry_referrals( be,
61 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
64 send_ldap_result( conn, op, LDAP_REFERRAL,
65 e->e_dn, NULL, refs, NULL );
73 if ( ! access_allowed( be, conn, op, e,
74 ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
76 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
77 NULL, NULL, NULL, NULL );
82 if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
83 send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE,
84 NULL, NULL, NULL, NULL );
89 if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
90 send_ldap_result( conn, op, LDAP_COMPARE_TRUE,
91 NULL, NULL, NULL, NULL );
93 send_ldap_result( conn, op, LDAP_COMPARE_FALSE,
94 NULL, NULL, NULL, NULL );
99 cache_return_entry_r( &li->li_cache, e );