- /* Check for RDN attrs in entry */
- for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
- AttributeDescription *desc = NULL;
- MatchingRule *mr;
- int i;
-
- rc = slap_bv2ad( &rdn[ 0 ][ cnt ]->la_attr,
- &desc, &text );
-
- if ( rc != LDAP_SUCCESS ) {
- send_ldap_result( conn, op, rc,
- NULL, text, NULL, NULL );
- goto done;
- }
-
- for (mod = modlist; mod; mod = mod->sml_next) {
- AttributeDescription *mod_desc = NULL;
-
- rc = slap_bv2ad( &mod->sml_type,
- &mod_desc, &text );
- if ( rc != LDAP_SUCCESS ) {
- send_ldap_result( conn, op, rc,
- NULL, text, NULL, NULL );
- goto done;
- }
-
- if (mod_desc == desc) {
- break;
- }
- }
-
- if (mod == NULL) {
- struct berval bv;
-
-#define BAILOUT
-#ifdef BAILOUT
- /* bail out */
- send_ldap_result( conn, op,
- rc = LDAP_NO_SUCH_ATTRIBUTE,
- NULL,
- "attribute in RDN not listed in entry",
- NULL, NULL );
- goto done;
-
-#else /* ! BAILOUT */
- /* add attribute type and value to modlist */
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
-
- ber_dupbv( &mod->sml_type,
- &rdn[ 0 ][ cnt ]->la_attr );
-
- mod->sml_bvalues = NULL;
- ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
- ber_bvarray_add( &mod->sml_bvalues, &bv );
-
- *modtail = mod;
- modtail = &mod->sml_next;
- continue;
-#endif /* ! BAILOUT */
- }
-
- mr = desc->ad_type->sat_equality;
- if (mr == NULL || !mr->smr_match ) {
- /* bail out */
- send_ldap_result( conn, op,
- rc = LDAP_INVALID_SYNTAX,
- NULL,
- "attribute in RDN lacks matching rule",
- NULL, NULL );
- goto done;
- }
-
- for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
- int match = 0;
-
- rc = value_match(&match, desc, mr,
- SLAP_MR_VALUE_SYNTAX_MATCH,
- &mod->sml_bvalues[ i ],
- &rdn[ 0 ][ cnt ]->la_value, &text);
-
- if ( rc != LDAP_SUCCESS ) {
- send_ldap_result( conn, op, rc,
- NULL, text, NULL, NULL);
- goto done;
- }
-
- if (match == 0) {
- break;
- }
- }
-
- /* not found? */
- if (mod->sml_bvalues[ i ].bv_val == NULL) {
-#ifdef BAILOUT
- /* bailout */
- send_ldap_result( conn, op,
- rc = LDAP_NO_SUCH_ATTRIBUTE,
- NULL,
- "value in RDN not listed in entry",
- NULL, NULL );
- goto done;
-
-#else /* ! BAILOUT */
- struct berval bv;
-
- /* add attribute type and value to modlist */
- ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
- ber_bvarray_add( &mod->sml_bvalues, &bv );
- continue;
-#endif /* ! BAILOUT */
- }
- }