openldap/servers/slapd/back-ldbm/compare.c

63 lines
1.3 KiB
C
Raw Normal View History

1998-08-09 08:43:13 +08:00
/* compare.c - ldbm backend compare routine */
1998-10-25 09:41:42 +08:00
#include "portable.h"
1998-08-09 08:43:13 +08:00
#include <stdio.h>
1998-10-25 09:41:42 +08:00
#include <ac/socket.h>
#include <ac/string.h>
1998-08-09 08:43:13 +08:00
#include "slap.h"
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
1998-08-09 08:43:13 +08:00
int
ldbm_back_compare(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
Ava *ava
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *matched;
Entry *e;
Attribute *a;
1998-11-05 14:49:49 +08:00
int rc;
1998-08-09 08:43:13 +08:00
/* get entry with reader lock */
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
1998-08-09 08:43:13 +08:00
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
if(matched == NULL) free(matched);
1998-08-09 08:43:13 +08:00
return( 1 );
}
/* check for deleted */
if ( ! access_allowed( be, conn, op, e,
ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
{
1998-08-09 08:43:13 +08:00
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" );
rc = 1;
goto return_results;
1998-08-09 08:43:13 +08:00
}
if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE, "", "" );
rc = 1;
goto return_results;
1998-08-09 08:43:13 +08:00
}
if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
1998-08-09 08:43:13 +08:00
send_ldap_result( conn, op, LDAP_COMPARE_TRUE, "", "" );
else
send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" );
rc = 0;
1998-08-09 08:43:13 +08:00
return_results:;
cache_return_entry_r( &li->li_cache, e );
return( rc );
1998-08-09 08:43:13 +08:00
}