- out = NULL;
- bvdn = ber_bvstr( dn );
-
- if ( dnNormalize( NULL, bvdn, &nbvdn ) == LDAP_SUCCESS ) {
- if ( nbvdn->bv_len <= bvdn->bv_len ) {
- out = dn;
- strcpy( out, nbvdn->bv_val );
+ rc = slap_bv2ad( &ava->la_attr, &ad, &text );
+ if ( rc != LDAP_SUCCESS ) {
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ ava->la_private = ( void * )ad;
+ do_sort = 1;
+ }
+
+ /*
+ * Replace attr oid/name with the canonical name
+ */
+ ava->la_attr = ad->ad_cname;
+
+ if( flags & SLAP_LDAPDN_PRETTY ) {
+ transf = ad->ad_type->sat_syntax->ssyn_pretty;
+ mr = NULL;
+ } else {
+ transf = ad->ad_type->sat_syntax->ssyn_normalize;
+ mr = ad->ad_type->sat_equality;
+ }
+
+ if ( transf ) {
+ /*
+ * transform value by normalize/pretty function
+ */
+ rc = ( *transf )( ad->ad_type->sat_syntax,
+ &ava->la_value, &bv );
+
+ if ( rc != LDAP_SUCCESS ) {
+ return LDAP_INVALID_SYNTAX;
+ }
+ }
+
+ if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
+ char *s = bv.bv_val;
+
+ ber_str2bv( UTF8normalize( bv.bv_val ? &bv
+ : &ava->la_value, LDAP_UTF8_CASEFOLD ),
+ 0, 0, &bv );
+ free( s );
+ }
+
+ if( bv.bv_val ) {
+ free( ava->la_value.bv_val );
+ ava->la_value = bv;
+ }
+
+ if( do_sort ) AVA_Sort( rdn, iAVA );