Avoid including libds/common/roles.h in public loadparm.h header.
[obnox/samba/samba-obnox.git] / source4 / dsdb / repl / drepl_service.c
index 0931a340b1a5043ea89776b9226cb4095726c271..2176da2d53d988295479181497644adae12371c9 100644 (file)
@@ -33,6 +33,7 @@
 #include "librpc/gen_ndr/ndr_drsblobs.h"
 #include "librpc/gen_ndr/ndr_irpc.h"
 #include "param/param.h"
+#include "libds/common/roles.h"
 
 /**
  * Call-back data for _drepl_replica_sync_done_cb()
@@ -306,6 +307,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
                        werr = dreplsrv_partition_source_dsa_by_guid(p,
                                                                     &req1->source_dsa_guid,
                                                                     &dsa);
+                       if (W_ERROR_EQUAL(werr, WERR_DS_DRA_NO_REPLICA)) {
+                               /* we don't have this source setup as
+                                  a replication partner. Create a
+                                  temporary dsa structure for this
+                                  replication */
+                               werr = dreplsrv_partition_source_dsa_temporary(p,
+                                                                              msg,
+                                                                              &req1->source_dsa_guid,
+                                                                              &dsa);
+                       }
                }
                if (!W_ERROR_IS_OK(werr)) {
                        REPLICA_SYNC_FAIL("Failed to locate source DSA for given NC",
@@ -328,7 +339,7 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
         * schedule replication event to force
         * replication as soon as possible
         */
-       dreplsrv_periodic_schedule(service, 0);
+       dreplsrv_pendingops_schedule(service, 0);
 
 done:
        return NT_STATUS_OK;
@@ -424,7 +435,7 @@ static void dreplsrv_task_init(struct task_server *task)
                task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration",
                                      false);
                return;
-       case ROLE_DOMAIN_CONTROLLER:
+       case ROLE_ACTIVE_DIRECTORY_DC:
                /* Yes, we want DSDB replication */
                break;
        }
@@ -497,7 +508,7 @@ static void dreplsrv_task_init(struct task_server *task)
        IRPC_REGISTER(task->msg_ctx, drsuapi, DRSUAPI_DSREPLICAMOD, dreplsrv_replica_mod, service);
        IRPC_REGISTER(task->msg_ctx, irpc, DREPL_TAKEFSMOROLE, drepl_take_FSMO_role, service);
        IRPC_REGISTER(task->msg_ctx, irpc, DREPL_TRIGGER_REPL_SECRET, drepl_trigger_repl_secret, service);
-       messaging_register(task->msg_ctx, service, MSG_DREPL_ALLOCATE_RID, dreplsrv_allocate_rid);
+       imessaging_register(task->msg_ctx, service, MSG_DREPL_ALLOCATE_RID, dreplsrv_allocate_rid);
 }
 
 /*