#include <ac/string.h>
#include <ac/time.h>
-#include "lutil.h"
-
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
#include "slapi.h"
#endif
+#include "lutil.h"
+
int
do_modify(
}
#endif
}
-#endif
if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
char abuf[BUFSIZ/2], *ptr = abuf;
op->o_connid, op->o_opid, abuf, 0, 0 );
}
}
+#endif /* LDAP_DEBUG */
manageDSAit = get_manageDSAit( op );
/*
* check values
*/
- if( ml->sml_bvalues != NULL ) {
+ if( ml->sml_values != NULL ) {
ber_len_t nvals;
slap_syntax_validate_func *validate =
ad->ad_type->sat_syntax->ssyn_validate;
* check that each value is valid per syntax
* and pretty if appropriate
*/
- for( nvals = 0; ml->sml_bvalues[nvals].bv_val; nvals++ ) {
+ for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
struct berval pval;
if( pretty ) {
rc = pretty( ad->ad_type->sat_syntax,
- &ml->sml_bvalues[nvals], &pval );
+ &ml->sml_values[nvals], &pval );
} else {
rc = validate( ad->ad_type->sat_syntax,
- &ml->sml_bvalues[nvals] );
+ &ml->sml_values[nvals] );
}
if( rc != 0 ) {
}
if( pretty ) {
- ber_memfree( ml->sml_bvalues[nvals].bv_val );
- ml->sml_bvalues[nvals] = pval;
+ ber_memfree( ml->sml_values[nvals].bv_val );
+ ml->sml_values[nvals] = pval;
}
}
* a rough single value check... an additional check is needed
* to catch add of single value to existing single valued attribute
*/
- if( ( ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE )
+ if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
&& nvals > 1 && is_at_single_value( ad->ad_type ))
{
snprintf( textbuf, textlen,
- "%s: multiple value provided",
+ "%s: multiple values provided",
ml->sml_type.bv_val );
*text = textbuf;
return LDAP_CONSTRAINT_VIOLATION;
}
+
+#ifdef SLAP_NVALUES
+ if( nvals && ad->ad_type->sat_equality &&
+ ad->ad_type->sat_equality->smr_normalize )
+ {
+ ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) );
+ for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
+ rc = ad->ad_type->sat_equality->smr_normalize(
+ 0,
+ ad->ad_type->sat_syntax,
+ ad->ad_type->sat_equality,
+ &ml->sml_values[nvals], &ml->sml_nvalues[nvals] );
+ if( rc ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, DETAIL1,
+ "str2entry: NULL (ssyn_normalize %d)\n",
+ rc, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "<= str2entry NULL (ssyn_normalize %d)\n",
+ rc, 0, 0 );
+#endif
+ snprintf( textbuf, textlen,
+ "%s: value #%ld normalization failed",
+ ml->sml_type.bv_val, (long) nvals );
+ *text = textbuf;
+ return rc;
+ }
+ }
+ ml->sml_nvalues[nvals].bv_val = NULL;
+ ml->sml_nvalues[nvals].bv_len = 0;
+ }
+#endif
}
}
char *textbuf, size_t textlen )
{
struct berval name, timestamp, csn;
+#ifdef SLAP_NVALUES
+ struct berval nname;
+#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
Modifications *mod;
if( op->o_dn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
+#ifdef SLAP_NVALUES
+ nname = name;
+#endif
} else {
name = op->o_dn;
+#ifdef SLAP_NVALUES
+ nname = op->o_ndn;
+#endif
}
}
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
- mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ mod->sml_values =
+ (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &tmpval );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues =
+ (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_nvalues[0], &tmpval );
+ mod->sml_nvalues[1].bv_len = 0;
+ mod->sml_nvalues[1].bv_val = NULL;
+ assert( mod->sml_nvalues[0].bv_val );
+#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_entryUUID;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
- mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ mod->sml_values =
+ (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &tmpval );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues = NULL;
+#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_creatorsName;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &name );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues =
+ (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_nvalues[0], &nname );
+ mod->sml_nvalues[1].bv_len = 0;
+ mod->sml_nvalues[1].bv_val = NULL;
+ assert( mod->sml_nvalues[0].bv_val );
+#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_createTimestamp;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], ×tamp );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues = NULL;
+#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_entryCSN;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &csn );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues = NULL;
+#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_modifiersName;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], &name );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues =
+ (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_nvalues[0], &nname );
+ mod->sml_nvalues[1].bv_len = 0;
+ mod->sml_nvalues[1].bv_val = NULL;
+ assert( mod->sml_nvalues[0].bv_val );
+#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_op = mop;
mod->sml_type.bv_val = NULL;
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = NULL;
-#endif
mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_values[0], ×tamp );
+ mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
+#ifdef SLAP_NVALUES
+ mod->sml_nvalues = NULL;
+#endif
*modtail = mod;
modtail = &mod->sml_next;
}