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"
|
1998-09-21 04:22:46 +08:00
|
|
|
#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
|
|
|
|
1998-09-21 04:22:46 +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, "" );
|
1998-11-24 04:08:25 +08:00
|
|
|
|
|
|
|
if(matched == NULL) free(matched);
|
1998-08-09 08:43:13 +08:00
|
|
|
return( 1 );
|
|
|
|
}
|
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
/* check for deleted */
|
1999-01-19 13:10:50 +08:00
|
|
|
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, "", "" );
|
1998-09-21 04:22:46 +08:00
|
|
|
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, "", "" );
|
1998-09-21 04:22:46 +08:00
|
|
|
rc = 1;
|
|
|
|
goto return_results;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
1998-09-21 04:22:46 +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, "", "" );
|
1998-09-21 04:22:46 +08:00
|
|
|
else
|
|
|
|
send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" );
|
|
|
|
|
|
|
|
rc = 0;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-09-21 04:22:46 +08:00
|
|
|
return_results:;
|
|
|
|
cache_return_entry_r( &li->li_cache, e );
|
|
|
|
return( rc );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|