#include "rpc_server/drsuapi/dcesrv_drsuapi.h"
#include "auth/session.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
+#include "librpc/gen_ndr/ndr_irpc_c.h"
+#include "lib/messaging/irpc.h"
struct repsTo {
uint32_t count;
return WERR_OK;
}
+struct drepl_refresh_state {
+ struct dreplsrv_refresh r;
+};
+
/**
* @brief Update the references for the given NC and the destination DSA object
*
* will validate the request to update reference and then will add/del a repsTo
* to the specified server referenced by its DSA GUID in the request.
*
+ * @param[in] msg_ctx Messaging context for sending partition
+ * refresh in dreplsrv
+ *
* @param[in] b_state A bind_state object
*
* @param[in] mem_ctx A talloc context for memory allocation
* @return WERR_OK is success, different error
* otherwise.
*/
-WERROR drsuapi_UpdateRefs(struct drsuapi_bind_state *b_state, TALLOC_CTX *mem_ctx,
+WERROR drsuapi_UpdateRefs(struct imessaging_context *msg_ctx,
+ struct tevent_context *event_ctx,
+ struct drsuapi_bind_state *b_state, TALLOC_CTX *mem_ctx,
struct drsuapi_DsReplicaUpdateRefsRequest1 *req)
{
WERROR werr;
struct ldb_dn *dn;
struct ldb_dn *nc_root;
struct ldb_context *sam_ctx = b_state->sam_ctx_system?b_state->sam_ctx_system:b_state->sam_ctx;
+ struct dcerpc_binding_handle *irpc_handle;
+ struct tevent_req *subreq;
+ struct drepl_refresh_state *state;
+
DEBUG(4,("DsReplicaUpdateRefs for host '%s' with GUID %s options 0x%08x nc=%s\n",
req->dest_dsa_dns_name, GUID_string(mem_ctx, &req->dest_dsa_guid),
if (req->options & DRSUAPI_DRS_ADD_REF) {
struct repsFromTo1 dest;
struct repsFromTo1OtherInfo oi;
-
+
ZERO_STRUCT(dest);
ZERO_STRUCT(oi);
if (ldb_transaction_commit(sam_ctx) != LDB_SUCCESS) {
DEBUG(0,(__location__ ": Failed to commit transaction on samdb: %s\n",
ldb_errstring(sam_ctx)));
- return WERR_DS_DRA_INTERNAL_ERROR;
+ return WERR_DS_DRA_INTERNAL_ERROR;
}
+ state = talloc_zero(mem_ctx, struct drepl_refresh_state);
+ if (state == NULL) {
+ return WERR_OK;
+ }
+
+ irpc_handle = irpc_binding_handle_by_name(mem_ctx, msg_ctx,
+ "dreplsrv", &ndr_table_irpc);
+ if (irpc_handle == NULL) {
+ /* dreplsrv is not running yet */
+ TALLOC_FREE(state);
+ return WERR_OK;
+ }
+
+ /*
+ * [Taken from auth_sam_trigger_repl_secret in auth_sam.c]
+ *
+ * This seem to rely on the current IRPC implementation,
+ * which delivers the message in the _send function.
+ *
+ * TODO: we need a ONE_WAY IRPC handle and register
+ * a callback and wait for it to be triggered!
+ */
+ subreq = dcerpc_dreplsrv_refresh_r_send(state, event_ctx,
+ irpc_handle, &state->r);
+ TALLOC_FREE(subreq);
+ TALLOC_FREE(state);
+
return WERR_OK;
failed:
}
}
- werr = drsuapi_UpdateRefs(b_state, mem_ctx, req);
+ werr = drsuapi_UpdateRefs(dce_call->msg_ctx, dce_call->event_ctx,
+ b_state, mem_ctx, req);
#if 0
NDR_PRINT_FUNCTION_DEBUG(drsuapi_DsReplicaUpdateRefs, NDR_BOTH, r);