/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2014 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Attribute *oldattrs,
int manage,
int add,
+ Attribute **socp,
const char** text,
char *textbuf, size_t textlen )
{
rc = LDAP_OBJECT_CLASS_VIOLATION;
goto done;
- } else if ( sc != slap_schema.si_oc_glue && sc != oc ) {
- snprintf( textbuf, textlen,
- "structural object class modification "
- "from '%s' to '%s' not allowed",
- asc->a_vals[0].bv_val, oc->soc_cname.bv_val );
- rc = LDAP_NO_OBJECT_CLASS_MODS;
- goto done;
- } else if ( sc == slap_schema.si_oc_glue ) {
+ } else if ( sc != oc ) {
+ if ( !manage && sc != slap_schema.si_oc_glue ) {
+ snprintf( textbuf, textlen,
+ "structural object class modification "
+ "from '%s' to '%s' not allowed",
+ asc->a_vals[0].bv_val, oc->soc_cname.bv_val );
+ rc = LDAP_NO_OBJECT_CLASS_MODS;
+ goto done;
+ }
+
+ assert( asc->a_vals != NULL );
+ assert( !BER_BVISNULL( &asc->a_vals[0] ) );
+ assert( BER_BVISNULL( &asc->a_vals[1] ) );
+ assert( asc->a_nvals == asc->a_vals );
+
+ /* draft-zeilenga-ldap-relax: automatically modify
+ * structuralObjectClass if changed with relax */
sc = oc;
+ ber_bvreplace( &asc->a_vals[ 0 ], &sc->soc_cname );
+ if ( socp ) {
+ *socp = asc;
+ }
}
/* naming check */
if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&p,
LDAP_DN_FORMAT_LDAP ) )
{
- *text = "unrecongized attribute type(s) in RDN";
+ *text = "unrecognized attribute type(s) in RDN";
return LDAP_INVALID_DN_SYNTAX;
}
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
&ava->la_value, NULL, NULL );
- if( rc != 0 ) {
+ if ( rc != 0 ) {
switch( rc ) {
case LDAP_INAPPROPRIATE_MATCHING:
snprintf( textbuf, textlen,
break;
case LDAP_NO_SUCH_ATTRIBUTE:
if ( add_naming ) {
- add = 1;
- rc = LDAP_SUCCESS;
+ if ( is_at_single_value( desc->ad_type ) ) {
+ snprintf( textbuf, textlen,
+ "value of single-valued naming attribute '%s' conflicts with value present in entry",
+ ava->la_attr.bv_val );
+
+ } else {
+ add = 1;
+ rc = LDAP_SUCCESS;
+ }
+
} else {
snprintf( textbuf, textlen,
"value of naming attribute '%s' is not present in entry",