From 2f5fbeb180959bf7507ff6fba71871e22bc0b422 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 11 Aug 2003 02:12:20 +0000 Subject: [PATCH] ITS#2664: add uniqueMemberMatch --- servers/slapd/schema_init.c | 75 +++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 732b706d7b..43bad4b552 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -28,9 +28,6 @@ #define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len) #define HASH_Final(d,c) lutil_HASHFinal(d,c) -/* not yet implemented */ -#define uniqueMemberMatch NULL - #define OpenLDAPaciMatch NULL /* approx matching rules */ @@ -795,6 +792,77 @@ uniqueMemberNormalize( return LDAP_SUCCESS; } +static int +uniqueMemberMatch( + int *matchp, + slap_mask_t flags, + Syntax *syntax, + MatchingRule *mr, + struct berval *value, + void *assertedValue ) +{ + int match; + struct berval *asserted = (struct berval *) assertedValue; + struct berval assertedDN = { 0, NULL }; + struct berval assertedUID = { 0, NULL }; + struct berval valueDN = { 0, NULL }; + struct berval valueUID = { 0, NULL }; + + if( asserted->bv_len != 0 ) { + assertedDN = *asserted; + + if( assertedDN.bv_val[assertedDN.bv_len-1] == 'B' + && assertedDN.bv_val[assertedDN.bv_len-2] == '\'' ) + { + /* assume presence of optional UID */ + assertedUID.bv_val = strrchr( assertedDN.bv_val, '#' ); + + if( assertedUID.bv_val == NULL ) { + return LDAP_INVALID_SYNTAX; + } + + assertedUID.bv_len = assertedDN.bv_len - + (assertedUID.bv_val - assertedDN.bv_val); + assertedDN.bv_len -= assertedUID.bv_len--; + + /* trim the separator */ + assertedUID.bv_val++; + } + } + + if( value->bv_len != 0 ) { + valueDN = *value; + + if( valueDN.bv_val[valueDN.bv_len-1] == 'B' + && valueDN.bv_val[valueDN.bv_len-2] == '\'' ) + { + /* assume presence of optional UID */ + valueUID.bv_val = strrchr( valueDN.bv_val, '#' ); + + if( valueUID.bv_val == NULL ) { + return LDAP_INVALID_SYNTAX; + } + + valueUID.bv_len = valueDN.bv_len - + (assertedUID.bv_val - assertedDN.bv_val); + valueDN.bv_len -= valueUID.bv_len--; + + /* trim the separator */ + valueUID.bv_val++; + } + } + + if( valueUID.bv_len && assertedUID.bv_len ) { + match = memcmp( valueUID.bv_val, assertedUID.bv_val, valueUID.bv_len ); + if( match ) { + *matchp = match; + return LDAP_SUCCESS; + } + } + + return dnMatch( matchp, flags, syntax, mr, &valueDN, &assertedDN ); +} + /* * Handling boolean syntax and matching is quite rigid. * A more flexible approach would be to allow a variety @@ -2313,6 +2381,7 @@ firstComponentNormalize( return rc; } + #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' " #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' " -- 2.39.5