mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
SLAPD_SCHEMA_NOT_COMPAT: cheap DN match
This commit is contained in:
parent
30c43c307c
commit
e31e42374e
1 changed files with 73 additions and 4 deletions
|
|
@ -16,6 +16,76 @@
|
|||
#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 )",
|
||||
|
|
|
|||
Loading…
Reference in a new issue