]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/delete.c
- LDAP_SYNCREPL defined in include/ldap.h
[openldap] / servers / slapd / delete.c
index facf238f44676dae2435a17ec3cfa75e9e989473..6f39f82e7158163512e48431155fae2ca456beb6 100644 (file)
@@ -131,11 +131,16 @@ do_delete(
                        NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
 
                if (!rs->sr_ref) rs->sr_ref = default_referral;
-               rs->sr_err = LDAP_REFERRAL;
+               if ( rs->sr_ref != NULL ) {
+                       rs->sr_err = LDAP_REFERRAL;
 
-               send_ldap_result( op, rs );
+                       send_ldap_result( op, rs );
 
-               if (rs->sr_ref!= default_referral) ber_bvarray_free( rs->sr_ref );
+                       if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
+               } else {
+                       send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+                                       "referral missing" );
+               }
                goto cleanup;
        }
 
@@ -168,8 +173,10 @@ do_delete(
                Debug (LDAP_DEBUG_TRACE, "do_delete: delete preoperation plugin failed.\n",
                                0, 0, 0);
 #endif
-               if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 )
+               if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 )  ||
+                    rs->sr_err == LDAP_SUCCESS ) {
                        rs->sr_err = LDAP_OTHER;
+               }
                goto cleanup;
        }
 #endif /* defined( LDAP_SLAPI ) */
@@ -183,7 +190,11 @@ do_delete(
        if ( op->o_bd->be_delete ) {
                /* do the update here */
                int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
+               if ( !op->o_bd->syncinfo && ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
+               if ( !op->o_bd->syncinfo )  /* LDAP_SYNCREPL overrides MM */
+#elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
                if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
 #endif
                {
@@ -195,14 +206,21 @@ do_delete(
                                        replog( op );
                                }
                        }
-#ifndef SLAPD_MULTIMASTER
+#if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
                } else {
-                       BerVarray defref = op->o_bd->be_update_refs
-                               ? op->o_bd->be_update_refs : default_referral;
+                       BerVarray defref = NULL;
+#ifdef LDAP_SYNCREPL
+                       if ( op->o_bd->syncinfo ) {
+                               defref = op->o_bd->syncinfo->master_bv;
+                       } else
+#endif
+                       {
+                               defref = op->o_bd->be_update_refs
+                                               ? op->o_bd->be_update_refs : default_referral;
+                       }
                        if ( defref != NULL ) {
-                               rs->sr_ref = referral_rewrite( default_referral,
+                               rs->sr_ref = referral_rewrite( defref,
                                        NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-
                                if (!rs->sr_ref) rs->sr_ref = defref;
                                rs->sr_err = LDAP_REFERRAL;
                                send_ldap_result( op, rs );