+ "do_modrdn: dn (%s) newrdn (%s) newsuperior (%s)\n",
+ dn.bv_val, newrdn.bv_val,
+ newSuperior.bv_len ? newSuperior.bv_val : "" );
+#endif
+
+ if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
+#endif
+
+ send_ldap_disconnect( conn, op,
+ LDAP_PROTOCOL_ERROR, "decoding error" );
+ rc = SLAPD_DISCONNECT;
+ goto cleanup;
+ }
+
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
+#endif
+
+ /* get_ctrls has sent results. Now clean up. */
+ goto cleanup;
+ }
+
+ rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
+ if( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, INFO,
+ "do_modrdn: conn %d invalid dn (%s)\n",
+ conn->c_connid, dn.bv_val, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "do_modrdn: invalid dn (%s)\n", dn.bv_val, 0, 0 );
+#endif
+ send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
+ "invalid DN", NULL, NULL );
+ goto cleanup;
+ }
+
+ if( ndn.bv_len == 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "do_modrdn: attempt to modify root DSE.\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "do_modrdn: root dse!\n", 0, 0, 0 );
+#endif
+
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+ NULL, "cannot rename the root DSE", NULL, NULL );
+ goto cleanup;
+
+ } else if ( bvmatch( &ndn, &global_schemandn ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "do_modrdn: attempt to modify subschema subentry: %s (%ld)\n",
+ global_schemandn.bv_val, (long) global_schemandn.bv_len, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "do_modrdn: subschema subentry: %s (%ld)\n",
+ global_schemandn.bv_val, (long) global_schemandn.bv_len, 0 );
+#endif
+
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+ NULL, "cannot rename subschema subentry", NULL, NULL );
+ goto cleanup;
+ }
+
+ /* FIXME: should have/use rdnPretty / rdnNormalize routines */
+
+ rc = dnPrettyNormal( NULL, &newrdn, &pnewrdn, &nnewrdn );
+ if( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, INFO,
+ "do_modrdn: conn %d invalid newrdn (%s)\n",
+ conn->c_connid, newrdn.bv_val, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "do_modrdn: invalid newrdn (%s)\n", newrdn.bv_val, 0, 0 );
+#endif
+ send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
+ "invalid new RDN", NULL, NULL );
+ goto cleanup;
+ }
+
+ if( rdnValidate( &pnewrdn ) != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "do_modrdn: invalid rdn (%s).\n", pnewrdn.bv_val, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n",
+ pnewrdn.bv_val, 0, 0 );
+#endif
+
+ send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
+ "invalid new RDN", NULL, NULL );
+ goto cleanup;
+ }
+
+ if( pnewS ) {
+ rc = dnPrettyNormal( NULL, &newSuperior, &pnewSuperior,
+ &nnewSuperior );
+ if( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, INFO,
+ "do_modrdn: conn %d invalid newSuperior (%s)\n",
+ conn->c_connid, newSuperior.bv_val, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "do_modrdn: invalid newSuperior (%s)\n",
+ newSuperior.bv_val, 0, 0 );
+#endif
+ send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
+ "invalid newSuperior", NULL, NULL );
+ goto cleanup;
+ }
+ }
+
+ Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MODRDN dn=\"%s\"\n",
+ op->o_connid, op->o_opid, pdn.bv_val, 0, 0 );