]> git.sur5r.net Git - openldap/commitdiff
SLAPD_SCHEMA_NOT_COMPAT: cheap DN match
authorKurt Zeilenga <kurt@openldap.org>
Mon, 29 May 2000 00:27:49 +0000 (00:27 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 29 May 2000 00:27:49 +0000 (00:27 +0000)
servers/slapd/schema_init.c

index 7814abdf7a0a58eba14b61a1e4d1396eb2b79e75..79867ec929e8775e3d8a3bf5ae5e233a813beef4 100644 (file)
 #include "slap.h"
 #include "ldap_pvt.h"
 
+static int
+dnValidate(
+       Syntax *syntax,
+       struct berval *in )
+{
+       int rc;
+       char *dn;
+
+       if( in->bv_len == 0 ) return LDAP_SUCCESS;
+
+       dn = ch_strdup( in->bv_val );
+
+       rc = dn_validate( dn ) == NULL
+               ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
+
+       ch_free( dn );
+       return rc;
+}
+
+static int
+dnNormalize(
+       Syntax *syntax,
+       struct berval *val,
+       struct berval **normalized )
+{
+       struct berval *out = ber_bvdup( val );
+
+       if( out->bv_len != 0 ) {
+               char *dn;
+#ifdef USE_DN_NORMALIZE
+               dn = dn_normalize( out->bv_val );
+#else
+               dn = dn_validate( out->bv_val );
+#endif
+
+               if( dn == NULL ) {
+                       ber_bvfree( out );
+                       return LDAP_INVALID_SYNTAX;
+               }
+
+               out->bv_val = dn;
+               out->bv_len = strlen( dn );
+       }
+
+       *normalized = out;
+       return LDAP_SUCCESS;
+}
+
+static int
+dnMatch(
+       int *match,
+       unsigned use,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *asserted = (struct berval *) assertedValue;
+       ber_slen_t diff;
+       
+       diff = value->bv_len - asserted->bv_len;
+       if( diff ) return diff;
+       
+#ifdef USE_DN_NORMALIZE
+       return strcmp( value->bv_val, asserted->bv_val );
+#else
+       return strcasecmp( value->bv_val, asserted->bv_val );
+#endif
+}
+       
 static int
 inValidate(
        Syntax *syntax,
@@ -631,8 +701,8 @@ struct syntax_defs_rec syntax_defs[] = {
                SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
                0, NULL, NULL, NULL},
-       {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'DN' )",
-               0, blobValidate, NULL, NULL},
+       {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
+               0, dnValidate, dnNormalize, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
@@ -779,7 +849,6 @@ struct mrule_defs_rec {
 
 /* unimplemented matching functions */
 #define objectIdentifierMatch NULL
-#define distinguishedNameMatch NULL
 #define numericStringMatch NULL
 #define numericStringSubstringsMatch NULL
 #define caseIgnoreListMatch NULL
@@ -806,7 +875,7 @@ struct mrule_defs_rec mrule_defs[] = {
        {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT,
-               NULL, NULL, distinguishedNameMatch, NULL, NULL},
+               NULL, NULL, dnMatch, NULL, NULL},
 
        {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",