1 /* compare.c - bdb2 backend compare routine */
11 #include "back-bdb2.h"
12 #include "proto-back-bdb2.h"
15 bdb2i_back_compare_internal(
23 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
28 int manageDSAit = get_manageDSAit( op );
30 /* get entry with reader lock */
31 if ( (e = bdb2i_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 bdb2i_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 bdb2i_cache_return_entry_r( &li->li_cache, e );
114 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
115 struct timeval time1;
118 bdb2i_start_timing( be->bd_info, &time1 );
120 if ( bdb2i_enter_backend_r( &lock ) != 0 ) {
122 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
123 NULL, NULL, NULL, NULL );
128 ret = bdb2i_back_compare_internal( be, conn, op, dn, ava );
129 (void) bdb2i_leave_backend_r( lock );
130 bdb2i_stop_timing( be->bd_info, time1, "CMP", conn, op );