schema.c schema_check.c schema_init.c schema_prep.c \
schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
monitor.c configinfo.c starttls.c index.c sets.c\
- root_dse.c sasl.c module.c suffixalias.c $(@PLAT@_SRCS)
+ root_dse.c sasl.c module.c suffixalias.c mra.c $(@PLAT@_SRCS)
OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
attr.o entry.o config.o backend.o result.o operation.o \
schema.o schema_check.o schema_init.o schema_prep.o \
schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
monitor.o configinfo.o starttls.o index.o sets.o\
- root_dse.o sasl.o module.o suffixalias.o $(@PLAT@_OBJS)
+ root_dse.o sasl.o module.o suffixalias.o mra.o $(@PLAT@_OBJS)
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
break;
case LDAP_FILTER_EXT:
- /* not yet implemented */
- Debug( LDAP_DEBUG_ANY, "extensible match not yet implemented.\n",
- 0, 0, 0 );
- (void) ber_skip_tag( ber, &len );
- f->f_choice = SLAPD_FILTER_COMPUTED;
- f->f_result = SLAPD_COMPARE_UNDEFINED;
- *fstr = ch_strdup( "(extended)" );
+ Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 );
+
+ err = get_mra( ber, &f->f_mra, text );
+ if ( err != LDAP_SUCCESS ) {
+ break;
+ }
+
+ assert( f->f_mra != NULL );
+
+ filter_escape_value( f->f_mr_value, &escaped );
+
+ *fstr = ch_malloc( sizeof("(:dn::=)")
+ + (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_len : 0)
+ + (f->f_mr_rule ? strlen(f->f_mr_rule) : 0)
+ + escaped.bv_len );
+
+ sprintf( *fstr, "(%s%s%s%s:=%s)",
+ (f->f_mr_desc ? f->f_mr_desc->ad_cname->bv_val : ""),
+ (f->f_mr_dnattrs ? ":dn" : ""),
+ (f->f_mr_rule ? ":" : ""),
+ (f->f_mr_rule ? f->f_mr_rule : ""),
+ f->f_mr_desc->ad_cname->bv_val,
+ escaped.bv_val );
+
+ ber_memfree( escaped.bv_val );
break;
default:
--- /dev/null
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* mra.c - routines for dealing with extensible matching rule assertions */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+
+
+void
+mra_free(
+ MatchingRuleAssertion *mra,
+ int freeit
+)
+{
+ ad_free( mra->ma_desc, 1 );
+ ch_free( (char *) mra->ma_rule );
+ ber_bvfree( mra->ma_value );
+ if ( freeit ) {
+ ch_free( (char *) mra );
+ }
+}
+
+int
+get_mra(
+ BerElement *ber,
+ MatchingRuleAssertion **mra,
+ const char **text
+)
+{
+ int rc, tag;
+ struct berval type, value, *nvalue;
+ MatchingRuleAssertion *ma;
+
+ ma = ch_malloc( sizeof( MatchingRuleAssertion ) );
+ ma->ma_rule = NULL;
+ ma->ma_desc = NULL;
+ ma->ma_dnattrs = 0;
+ ma->ma_value = NULL;
+
+ rc = ber_scanf( ber, "{t", &tag );
+
+ if( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
+ *text = "Error parsing matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+
+ if ( tag == LDAP_FILTER_EXT_OID ) {
+ rc = ber_scanf( ber, "a", &ma->ma_rule );
+ if ( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 );
+ *text = "Error parsing matching rule in matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+
+ rc = ber_scanf( ber, "t", &tag );
+
+ if( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
+ *text = "Error parsing matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+ }
+
+ if ( tag == LDAP_FILTER_EXT_TYPE ) {
+ rc = ber_scanf( ber, "o", &type );
+ if ( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for ad\n", 0, 0, 0 );
+ *text = "Error parsing attribute description in matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+
+ rc = slap_bv2ad( &type, &ma->ma_desc, text );
+ ch_free( type.bv_val );
+
+ if( rc != LDAP_SUCCESS ) {
+ ch_free( value.bv_val );
+ mra_free( ma, 1 );
+ return rc;
+ }
+
+ rc = ber_scanf( ber, "t", &tag );
+
+ if( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
+ *text = "Error parsing matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+ }
+
+ rc = ber_scanf( ber, "o", &value );
+
+ if( rc == LBER_ERROR ) {
+ Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
+ *text = "Error decoding value in matching rule assertion";
+ return SLAPD_DISCONNECT;
+ }
+
+ /*
+ * OK, if no matching rule, normalize for equality, otherwise
+ * normalize for the matching rule.
+ */
+ rc = value_normalize( ma->ma_desc, SLAP_MR_EQUALITY, &value, &nvalue, text );
+ ch_free( value.bv_val );
+
+ if( rc != LDAP_SUCCESS ) {
+ ad_free( ma->ma_desc, 1 );
+ ch_free( ma );
+ return rc;
+ }
+
+ ma->ma_value = nvalue;
+ *mra = ma;
+
+ return LDAP_SUCCESS;
+}
+