]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/modify.c
Preliminary ldapAdd support
[openldap] / servers / slapd / back-meta / modify.c
index 77e92da1455e791ed06a2c48168e3c4c19a2dc12..e09b9c35666347c744093e4da5a41ad4b6ca7f9c 100644 (file)
@@ -47,22 +47,15 @@ meta_back_modify( Operation *op, SlapReply *rs )
        dncookie        dc;
 
        lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
-                       &op->o_req_ndn, &candidate );
-       if ( !lc ) {
-               rc = -1;
-               goto cleanup;
+                       &op->o_req_ndn, &candidate, LDAP_BACK_SENDERR );
+       if ( !lc || !meta_back_dobind( lc, op, LDAP_BACK_SENDERR ) ) {
+               return rs->sr_err;
        }
        
-       if ( !meta_back_dobind( lc, op ) ) {
-               rs->sr_err = LDAP_UNAVAILABLE;
-
-       } else if ( !meta_back_is_valid( lc, candidate ) ) {
+       if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
-       }
-
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               rc = -1;
-               goto cleanup;
+               send_ldap_result( op, rs );
+               return rs->sr_err;
        }
 
        /*
@@ -134,15 +127,22 @@ meta_back_modify( Operation *op, SlapReply *rs )
                                mods[ i ].mod_bvalues =
                                        (struct berval **)ch_malloc( ( j + 1 ) *
                                        sizeof( struct berval * ) );
-                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); j++ ) {
-                                       ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_oc,
-                                                       &ml->sml_values[ j ],
-                                                       &mapped, BACKLDAP_MAP );
-                                       if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) )
-                                       {
-                                               continue;
+                               for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); ) {
+                                       struct ldapmapping      *mapping;
+
+                                       ldap_back_mapping( &li->targets[ candidate ]->mt_rwmap.rwm_oc,
+                                                       &ml->sml_values[ j ], &mapping, BACKLDAP_MAP );
+
+                                       if ( mapping == NULL ) {
+                                               if ( li->targets[ candidate ]->mt_rwmap.rwm_oc.drop_missing ) {
+                                                       continue;
+                                               }
+                                               mods[ i ].mod_bvalues[ j ] = &ml->sml_values[ j ];
+
+                                       } else {
+                                               mods[ i ].mod_bvalues[ j ] = &mapping->dst;
                                        }
-                                       mods[ i ].mod_bvalues[ j ] = &mapped;
+                                       j++;
                                }
                                mods[ i ].mod_bvalues[ j ] = NULL;
 
@@ -176,7 +176,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
        modv[ i ] = 0;
 
        rs->sr_err = ldap_modify_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val,
-                       modv, NULL, NULL );
+                       modv, op->o_ctrls, NULL );
 
 cleanup:;
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {