mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
SLAPD_SCHEMA_NOT_COMPAT: working modify? need additional match
routines, such as distinguishedNameMatch, to be sure.
This commit is contained in:
parent
3e3acf87c8
commit
30c43c307c
@ -290,10 +290,10 @@ attr_delete(
|
|||||||
*a = (*a)->a_next;
|
*a = (*a)->a_next;
|
||||||
attr_free( save );
|
attr_free( save );
|
||||||
|
|
||||||
return 0;
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return LDAP_NO_SUCH_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ int ldbm_modify_internal(
|
|||||||
err = add_values( e, mod, op->o_ndn );
|
err = add_values( e, mod, op->o_ndn );
|
||||||
|
|
||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
||||||
|
err, text, 0);
|
||||||
*text = "modify: add values failed";
|
*text = "modify: add values failed";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -69,6 +71,8 @@ int ldbm_modify_internal(
|
|||||||
err = delete_values( e, mod, op->o_ndn );
|
err = delete_values( e, mod, op->o_ndn );
|
||||||
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
|
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
|
||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
||||||
|
err, text, 0);
|
||||||
*text = "modify: delete values failed";
|
*text = "modify: delete values failed";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -78,6 +82,8 @@ int ldbm_modify_internal(
|
|||||||
err = replace_values( e, mod, op->o_ndn );
|
err = replace_values( e, mod, op->o_ndn );
|
||||||
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
|
assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
|
||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
||||||
|
err, text, 0);
|
||||||
*text = "modify: replace values failed";
|
*text = "modify: replace values failed";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -95,6 +101,8 @@ int ldbm_modify_internal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
||||||
|
err, text, 0);
|
||||||
*text = "modify: (soft)add values failed";
|
*text = "modify: (soft)add values failed";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -104,6 +112,8 @@ int ldbm_modify_internal(
|
|||||||
mod->sm_op, 0, 0);
|
mod->sm_op, 0, 0);
|
||||||
*text = "Invalid modify operation";
|
*text = "Invalid modify operation";
|
||||||
err = LDAP_OTHER;
|
err = LDAP_OTHER;
|
||||||
|
Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: %d %s\n",
|
||||||
|
err, text, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( err != LDAP_SUCCESS ) {
|
if ( err != LDAP_SUCCESS ) {
|
||||||
@ -331,34 +341,50 @@ add_values(
|
|||||||
Attribute *a;
|
Attribute *a;
|
||||||
|
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
AttributeDescription *desc = mod->sm_desc;
|
/* char *desc = mod->sm_desc->ad_cname->bv_val; */
|
||||||
|
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
|
||||||
|
|
||||||
|
if( mr == NULL ) {
|
||||||
|
return LDAP_INAPPROPRIATE_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
char *desc = mod->mod_type;
|
/* char *desc = mod->mod_type; */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
a = attr_find( e->e_attrs, desc );
|
a = attr_find( e->e_attrs, mod->sm_desc );
|
||||||
|
|
||||||
/* check if the values we're adding already exist */
|
/* check if the values we're adding already exist */
|
||||||
if ( a != NULL ) {
|
if ( a != NULL ) {
|
||||||
for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
|
for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
if ( value_find( desc, a->a_vals, mod->sm_bvalues[i] ) == 0 )
|
int j;
|
||||||
|
for ( j = 0; a->a_vals[j] != NULL; j++ ) {
|
||||||
|
int match;
|
||||||
|
const char *text = NULL;
|
||||||
|
int rc = value_match( &match, mod->sm_desc, mr,
|
||||||
|
mod->sm_bvalues[i], a->a_vals[j], &text );
|
||||||
|
|
||||||
|
if( rc == LDAP_SUCCESS && match == 0 ) {
|
||||||
|
return LDAP_TYPE_OR_VALUE_EXISTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if ( value_find( a->a_vals, mod->sm_bvalues[i],
|
if ( value_find( a->a_vals, mod->sm_bvalues[i],
|
||||||
a->a_syntax, 3 ) == 0 )
|
a->a_syntax, 3 ) == 0 ) {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
return( LDAP_TYPE_OR_VALUE_EXISTS );
|
return( LDAP_TYPE_OR_VALUE_EXISTS );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no - add them */
|
/* no - add them */
|
||||||
if( attr_merge( e, desc, mod->sm_bvalues ) != 0 ) {
|
if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
|
||||||
return( LDAP_CONSTRAINT_VIOLATION );
|
/* this should return result return of attr_merge */
|
||||||
|
return LDAP_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return( LDAP_SUCCESS );
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -372,6 +398,11 @@ delete_values(
|
|||||||
Attribute *a;
|
Attribute *a;
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
char *desc = mod->sm_desc->ad_cname->bv_val;
|
char *desc = mod->sm_desc->ad_cname->bv_val;
|
||||||
|
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
|
||||||
|
|
||||||
|
if( mr == NULL || !mr->smr_match ) {
|
||||||
|
return LDAP_INAPPROPRIATE_MATCHING;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
char *desc = mod->mod_type;
|
char *desc = mod->mod_type;
|
||||||
#endif
|
#endif
|
||||||
@ -399,7 +430,7 @@ delete_values(
|
|||||||
int match;
|
int match;
|
||||||
const char *text = NULL;
|
const char *text = NULL;
|
||||||
int rc = value_match( &match, mod->sm_desc,
|
int rc = value_match( &match, mod->sm_desc,
|
||||||
mod->sm_desc->ad_type->sat_equality,
|
mr,
|
||||||
mod->sm_bvalues[i], a->a_vals[j], &text );
|
mod->sm_bvalues[i], a->a_vals[j], &text );
|
||||||
|
|
||||||
if( rc == LDAP_SUCCESS && match != 0 )
|
if( rc == LDAP_SUCCESS && match != 0 )
|
||||||
@ -441,7 +472,7 @@ delete_values(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return( LDAP_SUCCESS );
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -451,13 +482,17 @@ replace_values(
|
|||||||
char *dn
|
char *dn
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(void) attr_delete( &e->e_attrs, mod->sm_desc );
|
int rc = attr_delete( &e->e_attrs, mod->sm_desc );
|
||||||
|
|
||||||
|
if( rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_ATTRIBUTE ) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
if ( mod->sm_bvalues != NULL &&
|
if ( mod->sm_bvalues != NULL &&
|
||||||
attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
|
attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
|
||||||
{
|
{
|
||||||
return( LDAP_CONSTRAINT_VIOLATION );
|
return LDAP_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return( LDAP_SUCCESS );
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -176,12 +176,16 @@ register_matching_rule(
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mr_add( mr, usage, convert, normalize, match, indexer, filter, &err );
|
code = mr_add( mr, usage,
|
||||||
|
convert, normalize, match, indexer, filter,
|
||||||
|
&err );
|
||||||
|
|
||||||
if ( code ) {
|
if ( code ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s for %s in %s\n",
|
Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s for %s in %s\n",
|
||||||
scherr2str(code), err, desc );
|
scherr2str(code), err, desc );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ value_add(
|
|||||||
}
|
}
|
||||||
(*vals)[n + j] = NULL;
|
(*vals)[n + j] = NULL;
|
||||||
|
|
||||||
return( 0 );
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
@ -289,7 +289,7 @@ value_find(
|
|||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
MatchingRule *mr = ad->ad_type->sat_equality;
|
MatchingRule *mr = ad->ad_type->sat_equality;
|
||||||
|
|
||||||
if( mr == NULL ) {
|
if( mr == NULL || !mr->smr_match ) {
|
||||||
return LDAP_INAPPROPRIATE_MATCHING;
|
return LDAP_INAPPROPRIATE_MATCHING;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user