s4:drepl_out_helpers: don't look at the internals of 'struct rpc_request'
[ira/wip.git] / source4 / dsdb / repl / drepl_service.c
index cb415b65e684a3ba19dbefd996361acd61cb04cb..3ed588566fae37e16b337fb133ba56ec03fe8220 100644 (file)
 
 static WERROR dreplsrv_init_creds(struct dreplsrv_service *service)
 {
-       NTSTATUS status;
-
-       status = auth_system_session_info(service, service->task->lp_ctx, 
-                                         &service->system_session_info);
-       if (!NT_STATUS_IS_OK(status)) {
-               return ntstatus_to_werror(status);
+       service->system_session_info = system_session(service->task->lp_ctx);
+       if (service->system_session_info == NULL) {
+               return WERR_NOMEM;
        }
 
        return WERR_OK;
@@ -83,7 +80,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct lo
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
-       bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_00100000;
+       bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
        bind_info28->supported_extensions       |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
@@ -113,18 +110,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 {
        struct dreplsrv_service *service = talloc_get_type(msg->private_data,
                                                           struct dreplsrv_service);
-       WERROR werr;
-       struct GUID *guid = &r->in.req.req1.naming_context->guid;
+       struct GUID *guid = &r->in.req->req1.naming_context->guid;
 
-       werr = dreplsrv_schedule_partition_pull_by_guid(service, msg, guid);
-       if (W_ERROR_IS_OK(werr)) {
+       r->out.result = dreplsrv_schedule_partition_pull_by_guid(service, msg, guid);
+       if (W_ERROR_IS_OK(r->out.result)) {
                DEBUG(3,("drepl_replica_sync: forcing sync of partition %s\n",
                         GUID_string(msg, guid)));
                dreplsrv_run_pending_ops(service);
        } else {
                DEBUG(3,("drepl_replica_sync: failed setup of sync of partition %s - %s\n",
-                        GUID_string(msg, guid), win_errstr(werr)));
-               return NT_STATUS_INTERNAL_ERROR;
+                        GUID_string(msg, guid), win_errstr(r->out.result)));
        }
        return NT_STATUS_OK;
 }
@@ -140,10 +135,12 @@ static void dreplsrv_task_init(struct task_server *task)
 
        switch (lp_server_role(task->lp_ctx)) {
        case ROLE_STANDALONE:
-               task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration");
+               task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration", 
+                                     false);
                return;
        case ROLE_DOMAIN_MEMBER:
-               task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration");
+               task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration", 
+                                     false);
                return;
        case ROLE_DOMAIN_CONTROLLER:
                /* Yes, we want DSDB replication */
@@ -154,7 +151,7 @@ static void dreplsrv_task_init(struct task_server *task)
 
        service = talloc_zero(task, struct dreplsrv_service);
        if (!service) {
-               task_server_terminate(task, "dreplsrv_task_init: out of memory");
+               task_server_terminate(task, "dreplsrv_task_init: out of memory", true);
                return;
        }
        service->task           = task;
@@ -165,7 +162,7 @@ static void dreplsrv_task_init(struct task_server *task)
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to obtain server credentials: %s\n",
-                                     win_errstr(status)));
+                                                           win_errstr(status)), true);
                return;
        }
 
@@ -173,7 +170,7 @@ static void dreplsrv_task_init(struct task_server *task)
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to connect to local samdb: %s\n",
-                                     win_errstr(status)));
+                                                           win_errstr(status)), true);
                return;
        }
 
@@ -181,7 +178,7 @@ static void dreplsrv_task_init(struct task_server *task)
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to load partitions: %s\n",
-                                     win_errstr(status)));
+                                                           win_errstr(status)), true);
                return;
        }
 
@@ -192,7 +189,7 @@ static void dreplsrv_task_init(struct task_server *task)
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to periodic schedule: %s\n",
-                                     win_errstr(status)));
+                                                           win_errstr(status)), true);
                return;
        }
 
@@ -202,13 +199,14 @@ static void dreplsrv_task_init(struct task_server *task)
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to setup notify schedule: %s\n",
-                                     win_errstr(status)));
+                                                           win_errstr(status)), true);
                return;
        }
 
        irpc_add_name(task->msg_ctx, "dreplsrv");
 
        IRPC_REGISTER(task->msg_ctx, drsuapi, DRSUAPI_DSREPLICASYNC, drepl_replica_sync, service);
+       messaging_register(task->msg_ctx, service, MSG_DREPL_ALLOCATE_RID, dreplsrv_allocate_rid);
 }
 
 /*