#include "../lib/util/tevent_ntstatus.h"
struct dreplsrv_out_drsuapi_state {
+ struct tevent_context *ev;
+
struct dreplsrv_out_connection *conn;
struct dreplsrv_drsuapi_connection *drsuapi;
return NULL;
}
+ state->ev = ev;
state->conn = conn;
state->drsuapi = conn->drsuapi;
return req;
}
-static void dreplsrv_out_drsuapi_bind_done(struct rpc_request *rreq);
+static void dreplsrv_out_drsuapi_bind_done(struct tevent_req *subreq);
static void dreplsrv_out_drsuapi_connect_done(struct composite_context *creq)
{
struct dreplsrv_out_drsuapi_state *state = tevent_req_data(req,
struct dreplsrv_out_drsuapi_state);
NTSTATUS status;
- struct rpc_request *rreq;
+ struct tevent_req *subreq;
status = dcerpc_pipe_connect_b_recv(creq,
state->drsuapi,
return;
}
+ state->drsuapi->drsuapi_handle = state->drsuapi->pipe->binding_handle;
+
status = gensec_session_key(state->drsuapi->pipe->conn->security_state.generic_state,
&state->drsuapi->gensec_skey);
if (tevent_req_nterror(req, status)) {
state->bind_r.in.bind_info = &state->bind_info_ctr;
state->bind_r.out.bind_handle = &state->drsuapi->bind_handle;
- rreq = dcerpc_drsuapi_DsBind_send(state->drsuapi->pipe,
- state,
- &state->bind_r);
- if (tevent_req_nomem(rreq, req)) {
+ subreq = dcerpc_drsuapi_DsBind_r_send(state,
+ state->ev,
+ state->drsuapi->drsuapi_handle,
+ &state->bind_r);
+ if (tevent_req_nomem(subreq, req)) {
return;
}
- composite_continue_rpc(NULL, rreq, dreplsrv_out_drsuapi_bind_done, req);
+ tevent_req_set_callback(subreq, dreplsrv_out_drsuapi_bind_done, req);
}
-static void dreplsrv_out_drsuapi_bind_done(struct rpc_request *rreq)
+static void dreplsrv_out_drsuapi_bind_done(struct tevent_req *subreq)
{
- struct tevent_req *req = talloc_get_type(rreq->async.private_data,
- struct tevent_req);
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
struct dreplsrv_out_drsuapi_state *state = tevent_req_data(req,
struct dreplsrv_out_drsuapi_state);
NTSTATUS status;
- status = dcerpc_ndr_request_recv(rreq);
+ status = dcerpc_drsuapi_DsBind_r_recv(subreq, state);
+ TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}
}
struct dreplsrv_op_pull_source_state {
- struct composite_context *creq;
-
+ struct tevent_context *ev;
struct dreplsrv_out_operation *op;
-
- struct dreplsrv_drsuapi_connection *drsuapi;
-
- bool have_all;
-
- uint32_t ctr_level;
- struct drsuapi_DsGetNCChangesCtr1 *ctr1;
- struct drsuapi_DsGetNCChangesCtr6 *ctr6;
+ void *ndr_struct_ptr;
};
static void dreplsrv_op_pull_source_connect_done(struct tevent_req *subreq);
-struct composite_context *dreplsrv_op_pull_source_send(struct dreplsrv_out_operation *op)
+struct tevent_req *dreplsrv_op_pull_source_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct dreplsrv_out_operation *op)
{
- struct composite_context *c;
- struct dreplsrv_op_pull_source_state *st;
+ struct tevent_req *req;
+ struct dreplsrv_op_pull_source_state *state;
struct tevent_req *subreq;
- c = composite_create(op, op->service->task->event_ctx);
- if (c == NULL) return NULL;
-
- st = talloc_zero(c, struct dreplsrv_op_pull_source_state);
- if (composite_nomem(st, c)) return c;
-
- st->creq = c;
- st->op = op;
+ req = tevent_req_create(mem_ctx, &state,
+ struct dreplsrv_op_pull_source_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->op = op;
- subreq = dreplsrv_out_drsuapi_send(st,
- op->service->task->event_ctx,
- op->source_dsa->conn);
- if (composite_nomem(subreq, c)) return c;
- tevent_req_set_callback(subreq, dreplsrv_op_pull_source_connect_done, st);
+ subreq = dreplsrv_out_drsuapi_send(state, ev, op->source_dsa->conn);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, dreplsrv_op_pull_source_connect_done, req);
- return c;
+ return req;
}
-static void dreplsrv_op_pull_source_get_changes_send(struct dreplsrv_op_pull_source_state *st);
+static void dreplsrv_op_pull_source_get_changes_trigger(struct tevent_req *req);
static void dreplsrv_op_pull_source_connect_done(struct tevent_req *subreq)
{
- struct dreplsrv_op_pull_source_state *st = tevent_req_callback_data(subreq,
- struct dreplsrv_op_pull_source_state);
- struct composite_context *c = st->creq;
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
+ NTSTATUS status;
- c->status = dreplsrv_out_drsuapi_recv(subreq);
+ status = dreplsrv_out_drsuapi_recv(subreq);
TALLOC_FREE(subreq);
- if (!composite_is_ok(c)) return;
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
- dreplsrv_op_pull_source_get_changes_send(st);
+ dreplsrv_op_pull_source_get_changes_trigger(req);
}
-static void dreplsrv_op_pull_source_get_changes_recv(struct rpc_request *req);
+static void dreplsrv_op_pull_source_get_changes_done(struct tevent_req *subreq);
-static void dreplsrv_op_pull_source_get_changes_send(struct dreplsrv_op_pull_source_state *st)
+/*
+ get a partial attribute set for a replication call
+ */
+static NTSTATUS dreplsrv_get_rodc_partial_attribute_set(struct dreplsrv_service *service,
+ TALLOC_CTX *mem_ctx,
+ struct drsuapi_DsPartialAttributeSet **_pas,
+ bool for_schema)
{
- struct composite_context *c = st->creq;
- struct repsFromTo1 *rf1 = st->op->source_dsa->repsFrom1;
- struct dreplsrv_service *service = st->op->service;
- struct dreplsrv_partition *partition = st->op->source_dsa->partition;
- struct dreplsrv_drsuapi_connection *drsuapi = st->op->source_dsa->conn->drsuapi;
- struct rpc_request *req;
+ struct drsuapi_DsPartialAttributeSet *pas;
+ struct dsdb_schema *schema;
+ int i;
+
+ pas = talloc_zero(mem_ctx, struct drsuapi_DsPartialAttributeSet);
+ NT_STATUS_HAVE_NO_MEMORY(pas);
+
+ schema = dsdb_get_schema(service->samdb, NULL);
+
+ pas->version = 1;
+ pas->attids = talloc_array(pas, enum drsuapi_DsAttributeId, schema->num_attributes);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(pas->attids, pas);
+
+ for (i=0; i<schema->num_attributes; i++) {
+ struct dsdb_attribute *a;
+ a = schema->attributes_by_attributeID_id[i];
+ if (a->systemFlags & (DS_FLAG_ATTR_NOT_REPLICATED | DS_FLAG_ATTR_IS_CONSTRUCTED)) {
+ continue;
+ }
+ if (a->searchFlags & SEARCH_FLAG_RODC_ATTRIBUTE) {
+ continue;
+ }
+ pas->attids[pas->num_attids] = dsdb_attribute_get_attid(a, for_schema);
+ pas->num_attids++;
+ }
+ *_pas = pas;
+ return NT_STATUS_OK;
+}
+
+static void dreplsrv_op_pull_source_get_changes_trigger(struct tevent_req *req)
+{
+ struct dreplsrv_op_pull_source_state *state = tevent_req_data(req,
+ struct dreplsrv_op_pull_source_state);
+ struct repsFromTo1 *rf1 = state->op->source_dsa->repsFrom1;
+ struct dreplsrv_service *service = state->op->service;
+ struct dreplsrv_partition *partition = state->op->source_dsa->partition;
+ struct dreplsrv_drsuapi_connection *drsuapi = state->op->source_dsa->conn->drsuapi;
struct drsuapi_DsGetNCChanges *r;
+ struct drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
+ struct tevent_req *subreq;
+ struct drsuapi_DsPartialAttributeSet *pas = NULL;
+ NTSTATUS status;
- r = talloc(st, struct drsuapi_DsGetNCChanges);
- if (composite_nomem(r, c)) return;
+ if ((rf1->replica_flags & DRSUAPI_DRS_WRIT_REP) == 0 &&
+ state->op->extended_op == DRSUAPI_EXOP_NONE) {
+ return;
+ }
+
+ r = talloc(state, struct drsuapi_DsGetNCChanges);
+ if (tevent_req_nomem(r, req)) {
+ return;
+ }
- r->out.level_out = talloc(r, int32_t);
- if (composite_nomem(r->out.level_out, c)) return;
+ r->out.level_out = talloc(r, uint32_t);
+ if (tevent_req_nomem(r->out.level_out, req)) {
+ return;
+ }
r->in.req = talloc(r, union drsuapi_DsGetNCChangesRequest);
- if (composite_nomem(r->in.req, c)) return;
+ if (tevent_req_nomem(r->in.req, req)) {
+ return;
+ }
r->out.ctr = talloc(r, union drsuapi_DsGetNCChangesCtr);
- if (composite_nomem(r->out.ctr, c)) return;
+ if (tevent_req_nomem(r->out.ctr, req)) {
+ return;
+ }
+
+ if (partition->uptodatevector_ex.count == 0) {
+ uptodateness_vector = NULL;
+ } else {
+ uptodateness_vector = &partition->uptodatevector_ex;
+ }
+
+ if (service->am_rodc) {
+ bool for_schema = false;
+ if (ldb_dn_compare_base(ldb_get_schema_basedn(service->samdb), partition->dn) == 0) {
+ for_schema = true;
+ }
+
+ status = dreplsrv_get_rodc_partial_attribute_set(service, r, &pas, for_schema);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,(__location__ ": Failed to construct partial attribute set : %s\n", nt_errstr(status)));
+ return;
+ }
+ }
r->in.bind_handle = &drsuapi->bind_handle;
if (drsuapi->remote_info28.supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) {
r->in.req->req8.source_dsa_invocation_id= rf1->source_dsa_invocation_id;
r->in.req->req8.naming_context = &partition->nc;
r->in.req->req8.highwatermark = rf1->highwatermark;
- r->in.req->req8.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/
+ r->in.req->req8.uptodateness_vector = uptodateness_vector;
r->in.req->req8.replica_flags = rf1->replica_flags;
r->in.req->req8.max_object_count = 133;
r->in.req->req8.max_ndr_size = 1336811;
- r->in.req->req8.extended_op = DRSUAPI_EXOP_NONE;
- r->in.req->req8.fsmo_info = 0;
- r->in.req->req8.partial_attribute_set = NULL;
+ r->in.req->req8.extended_op = state->op->extended_op;
+ r->in.req->req8.fsmo_info = state->op->fsmo_info;
+ r->in.req->req8.partial_attribute_set = pas;
r->in.req->req8.partial_attribute_set_ex= NULL;
r->in.req->req8.mapping_ctr.num_mappings= 0;
r->in.req->req8.mapping_ctr.mappings = NULL;
r->in.req->req5.source_dsa_invocation_id= rf1->source_dsa_invocation_id;
r->in.req->req5.naming_context = &partition->nc;
r->in.req->req5.highwatermark = rf1->highwatermark;
- r->in.req->req5.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/
+ r->in.req->req5.uptodateness_vector = uptodateness_vector;
r->in.req->req5.replica_flags = rf1->replica_flags;
r->in.req->req5.max_object_count = 133;
r->in.req->req5.max_ndr_size = 1336770;
- r->in.req->req5.extended_op = DRSUAPI_EXOP_NONE;
- r->in.req->req5.fsmo_info = 0;
+ r->in.req->req5.extended_op = state->op->extended_op;
+ r->in.req->req5.fsmo_info = state->op->fsmo_info;
}
- req = dcerpc_drsuapi_DsGetNCChanges_send(drsuapi->pipe, r, r);
- composite_continue_rpc(c, req, dreplsrv_op_pull_source_get_changes_recv, st);
+#if 0
+ NDR_PRINT_IN_DEBUG(drsuapi_DsGetNCChanges, r);
+#endif
+
+ state->ndr_struct_ptr = r;
+ subreq = dcerpc_drsuapi_DsGetNCChanges_r_send(state,
+ state->ev,
+ drsuapi->drsuapi_handle,
+ r);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, dreplsrv_op_pull_source_get_changes_done, req);
}
-static void dreplsrv_op_pull_source_apply_changes_send(struct dreplsrv_op_pull_source_state *st,
- struct drsuapi_DsGetNCChanges *r,
- uint32_t ctr_level,
- struct drsuapi_DsGetNCChangesCtr1 *ctr1,
- struct drsuapi_DsGetNCChangesCtr6 *ctr6);
+static void dreplsrv_op_pull_source_apply_changes_trigger(struct tevent_req *req,
+ struct drsuapi_DsGetNCChanges *r,
+ uint32_t ctr_level,
+ struct drsuapi_DsGetNCChangesCtr1 *ctr1,
+ struct drsuapi_DsGetNCChangesCtr6 *ctr6);
-static void dreplsrv_op_pull_source_get_changes_recv(struct rpc_request *req)
+static void dreplsrv_op_pull_source_get_changes_done(struct tevent_req *subreq)
{
- struct dreplsrv_op_pull_source_state *st = talloc_get_type(req->async.private_data,
- struct dreplsrv_op_pull_source_state);
- struct composite_context *c = st->creq;
- struct drsuapi_DsGetNCChanges *r = talloc_get_type(req->ndr.struct_ptr,
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct dreplsrv_op_pull_source_state *state = tevent_req_data(req,
+ struct dreplsrv_op_pull_source_state);
+ NTSTATUS status;
+ struct drsuapi_DsGetNCChanges *r = talloc_get_type(state->ndr_struct_ptr,
struct drsuapi_DsGetNCChanges);
uint32_t ctr_level = 0;
struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
+ enum drsuapi_DsExtendedError extended_ret;
+ state->ndr_struct_ptr = NULL;
- c->status = dcerpc_ndr_request_recv(req);
- if (!composite_is_ok(c)) return;
+ status = dcerpc_drsuapi_DsGetNCChanges_r_recv(subreq, r);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
if (!W_ERROR_IS_OK(r->out.result)) {
- composite_error(c, werror_to_ntstatus(r->out.result));
+ status = werror_to_ntstatus(r->out.result);
+ tevent_req_nterror(req, status);
return;
}
ctr_level = 6;
ctr6 = &r->out.ctr->ctr7.ctr.xpress6.ts->ctr6;
} else {
- composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP));
+ status = werror_to_ntstatus(WERR_BAD_NET_RESP);
+ tevent_req_nterror(req, status);
return;
}
if (!ctr1 && !ctr6) {
- composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP));
+ status = werror_to_ntstatus(WERR_BAD_NET_RESP);
+ tevent_req_nterror(req, status);
return;
}
if (ctr_level == 6) {
if (!W_ERROR_IS_OK(ctr6->drs_error)) {
- composite_error(c, werror_to_ntstatus(ctr6->drs_error));
+ status = werror_to_ntstatus(ctr6->drs_error);
+ tevent_req_nterror(req, status);
return;
}
+ extended_ret = ctr6->extended_ret;
}
- dreplsrv_op_pull_source_apply_changes_send(st, r, ctr_level, ctr1, ctr6);
+ if (ctr_level == 1) {
+ extended_ret = ctr1->extended_ret;
+ }
+
+ if (state->op->extended_op != DRSUAPI_EXOP_NONE) {
+ state->op->extended_ret = extended_ret;
+
+ if (extended_ret != DRSUAPI_EXOP_ERR_SUCCESS) {
+ status = NT_STATUS_UNSUCCESSFUL;
+ tevent_req_nterror(req, status);
+ return;
+ }
+ }
+
+ dreplsrv_op_pull_source_apply_changes_trigger(req, r, ctr_level, ctr1, ctr6);
}
-static void dreplsrv_update_refs_send(struct dreplsrv_op_pull_source_state *st);
+static void dreplsrv_update_refs_trigger(struct tevent_req *req);
-static void dreplsrv_op_pull_source_apply_changes_send(struct dreplsrv_op_pull_source_state *st,
- struct drsuapi_DsGetNCChanges *r,
- uint32_t ctr_level,
- struct drsuapi_DsGetNCChangesCtr1 *ctr1,
- struct drsuapi_DsGetNCChangesCtr6 *ctr6)
+static void dreplsrv_op_pull_source_apply_changes_trigger(struct tevent_req *req,
+ struct drsuapi_DsGetNCChanges *r,
+ uint32_t ctr_level,
+ struct drsuapi_DsGetNCChangesCtr1 *ctr1,
+ struct drsuapi_DsGetNCChangesCtr6 *ctr6)
{
- struct composite_context *c = st->creq;
- struct repsFromTo1 rf1 = *st->op->source_dsa->repsFrom1;
- struct dreplsrv_service *service = st->op->service;
- struct dreplsrv_partition *partition = st->op->source_dsa->partition;
- struct dreplsrv_drsuapi_connection *drsuapi = st->op->source_dsa->conn->drsuapi;
+ struct dreplsrv_op_pull_source_state *state = tevent_req_data(req,
+ struct dreplsrv_op_pull_source_state);
+ struct repsFromTo1 rf1 = *state->op->source_dsa->repsFrom1;
+ struct dreplsrv_service *service = state->op->service;
+ struct dreplsrv_partition *partition = state->op->source_dsa->partition;
+ struct dreplsrv_drsuapi_connection *drsuapi = state->op->source_dsa->conn->drsuapi;
const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
uint32_t object_count;
struct drsuapi_DsReplicaObjectListItemEx *first_object;
struct dsdb_extended_replicated_objects *objects;
bool more_data = false;
WERROR status;
+ NTSTATUS nt_status;
switch (ctr_level) {
case 1:
more_data = ctr6->more_data;
break;
default:
- composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP));
+ nt_status = werror_to_ntstatus(WERR_BAD_NET_RESP);
+ tevent_req_nterror(req, nt_status);
return;
}
&rf1,
uptodateness_vector,
&drsuapi->gensec_skey,
- st, &objects);
+ state, &objects);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status)));
- composite_error(c, werror_to_ntstatus(status));
+ nt_status = werror_to_ntstatus(WERR_BAD_NET_RESP);
+ DEBUG(0,("Failed to convert objects: %s/%s\n",
+ win_errstr(status), nt_errstr(nt_status)));
+ tevent_req_nterror(req, nt_status);
return;
}
status = dsdb_extended_replicated_objects_commit(service->samdb,
objects,
- &st->op->source_dsa->notify_uSN);
+ &state->op->source_dsa->notify_uSN);
talloc_free(objects);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
- composite_error(c, werror_to_ntstatus(status));
+ nt_status = werror_to_ntstatus(WERR_BAD_NET_RESP);
+ DEBUG(0,("Failed to commit objects: %s/%s\n",
+ win_errstr(status), nt_errstr(nt_status)));
+ tevent_req_nterror(req, nt_status);
return;
}
-
- /* if it applied fine, we need to update the highwatermark */
- *st->op->source_dsa->repsFrom1 = rf1;
-
+ if (state->op->extended_op == DRSUAPI_EXOP_NONE) {
+ /* if it applied fine, we need to update the highwatermark */
+ *state->op->source_dsa->repsFrom1 = rf1;
+ }
/*
* TODO: update our uptodatevector!
*/
+ /* we don't need this maybe very large structure anymore */
+ TALLOC_FREE(r);
+
if (more_data) {
- dreplsrv_op_pull_source_get_changes_send(st);
+ dreplsrv_op_pull_source_get_changes_trigger(req);
return;
}
we join the domain, but they quickly expire. We do it here
so we can use the already established DRSUAPI pipe
*/
- dreplsrv_update_refs_send(st);
+ if (state->op->extended_op == DRSUAPI_EXOP_NONE) {
+ dreplsrv_update_refs_trigger(req);
+ } else {
+ tevent_req_done(req);
+ }
}
-WERROR dreplsrv_op_pull_source_recv(struct composite_context *c)
+static void dreplsrv_update_refs_done(struct tevent_req *subreq);
+
+/*
+ send a UpdateRefs request to refresh our repsTo record on the server
+ */
+static void dreplsrv_update_refs_trigger(struct tevent_req *req)
{
- NTSTATUS status;
+ struct dreplsrv_op_pull_source_state *state = tevent_req_data(req,
+ struct dreplsrv_op_pull_source_state);
+ struct dreplsrv_service *service = state->op->service;
+ struct dreplsrv_partition *partition = state->op->source_dsa->partition;
+ struct dreplsrv_drsuapi_connection *drsuapi = state->op->source_dsa->conn->drsuapi;
+ struct drsuapi_DsReplicaUpdateRefs *r;
+ char *ntds_guid_str;
+ char *ntds_dns_name;
+ struct tevent_req *subreq;
+
+ r = talloc(state, struct drsuapi_DsReplicaUpdateRefs);
+ if (tevent_req_nomem(r, req)) {
+ return;
+ }
+
+ ntds_guid_str = GUID_string(r, &service->ntds_guid);
+ if (tevent_req_nomem(ntds_guid_str, req)) {
+ return;
+ }
- status = composite_wait(c);
+ ntds_dns_name = talloc_asprintf(r, "%s._msdcs.%s",
+ ntds_guid_str,
+ lpcfg_dnsdomain(service->task->lp_ctx));
+ if (tevent_req_nomem(ntds_dns_name, req)) {
+ return;
+ }
- talloc_free(c);
- return ntstatus_to_werror(status);
+ r->in.bind_handle = &drsuapi->bind_handle;
+ r->in.level = 1;
+ r->in.req.req1.naming_context = &partition->nc;
+ r->in.req.req1.dest_dsa_dns_name = ntds_dns_name;
+ r->in.req.req1.dest_dsa_guid = service->ntds_guid;
+ r->in.req.req1.options = DRSUAPI_DRS_ADD_REF | DRSUAPI_DRS_DEL_REF;
+ if (!service->am_rodc) {
+ r->in.req.req1.options |= DRSUAPI_DRS_WRIT_REP;
+ }
+
+ state->ndr_struct_ptr = r;
+ subreq = dcerpc_drsuapi_DsReplicaUpdateRefs_r_send(state,
+ state->ev,
+ drsuapi->drsuapi_handle,
+ r);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, dreplsrv_update_refs_done, req);
}
/*
receive a UpdateRefs reply
*/
-static void dreplsrv_update_refs_recv(struct rpc_request *req)
+static void dreplsrv_update_refs_done(struct tevent_req *subreq)
{
- struct dreplsrv_op_pull_source_state *st = talloc_get_type(req->async.private_data,
- struct dreplsrv_op_pull_source_state);
- struct composite_context *c = st->creq;
- struct drsuapi_DsReplicaUpdateRefs *r = talloc_get_type(req->ndr.struct_ptr,
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct dreplsrv_op_pull_source_state *state = tevent_req_data(req,
+ struct dreplsrv_op_pull_source_state);
+ struct drsuapi_DsReplicaUpdateRefs *r = talloc_get_type(state->ndr_struct_ptr,
struct drsuapi_DsReplicaUpdateRefs);
+ NTSTATUS status;
+
+ state->ndr_struct_ptr = NULL;
- c->status = dcerpc_ndr_request_recv(req);
- if (!composite_is_ok(c)) {
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs_r_recv(subreq, r);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("UpdateRefs failed with %s\n",
- nt_errstr(c->status)));
+ nt_errstr(status)));
+ tevent_req_nterror(req, status);
return;
}
if (!W_ERROR_IS_OK(r->out.result)) {
- DEBUG(0,("UpdateRefs failed with %s for %s %s\n",
+ status = werror_to_ntstatus(r->out.result);
+ DEBUG(0,("UpdateRefs failed with %s/%s for %s %s\n",
win_errstr(r->out.result),
+ nt_errstr(status),
r->in.req.req1.dest_dsa_dns_name,
r->in.req.req1.naming_context->dn));
- composite_error(c, werror_to_ntstatus(r->out.result));
+ tevent_req_nterror(req, status);
return;
}
r->in.req.req1.dest_dsa_dns_name,
r->in.req.req1.naming_context->dn));
- composite_done(c);
+ tevent_req_done(req);
}
-/*
- send a UpdateRefs request to refresh our repsTo record on the server
- */
-static void dreplsrv_update_refs_send(struct dreplsrv_op_pull_source_state *st)
+WERROR dreplsrv_op_pull_source_recv(struct tevent_req *req)
{
- struct composite_context *c = st->creq;
- struct dreplsrv_service *service = st->op->service;
- struct dreplsrv_partition *partition = st->op->source_dsa->partition;
- struct dreplsrv_drsuapi_connection *drsuapi = st->op->source_dsa->conn->drsuapi;
- struct rpc_request *req;
- struct drsuapi_DsReplicaUpdateRefs *r;
- char *ntds_guid_str;
- char *ntds_dns_name;
-
- r = talloc(st, struct drsuapi_DsReplicaUpdateRefs);
- if (composite_nomem(r, c)) return;
-
- ntds_guid_str = GUID_string(r, &service->ntds_guid);
- if (composite_nomem(ntds_guid_str, c)) return;
-
- ntds_dns_name = talloc_asprintf(r, "%s._msdcs.%s",
- ntds_guid_str,
- lp_dnsdomain(service->task->lp_ctx));
- if (composite_nomem(ntds_dns_name, c)) return;
+ NTSTATUS status;
- r->in.bind_handle = &drsuapi->bind_handle;
- r->in.level = 1;
- r->in.req.req1.naming_context = &partition->nc;
- r->in.req.req1.dest_dsa_dns_name = ntds_dns_name;
- r->in.req.req1.dest_dsa_guid = service->ntds_guid;
- r->in.req.req1.options =
- DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE |
- DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE;
- if (!samdb_rodc(service->task->lp_ctx)) {
- r->in.req.req1.options |= DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE;
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return ntstatus_to_werror(status);
}
- req = dcerpc_drsuapi_DsReplicaUpdateRefs_send(drsuapi->pipe, r, r);
- composite_continue_rpc(c, req, dreplsrv_update_refs_recv, st);
+ tevent_req_received(req);
+ return WERR_OK;
}
+