summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-01-23 15:43:14 +1100
committerAndrew Bartlett <abartlet@samba.org>2008-01-23 15:43:14 +1100
commit4172e09c5395b7004ada0d4a9e786bba6c159bc9 (patch)
tree974af47b37e97e54b7ff46bbcd6ef0c24aa694f8 /source4/dsdb/samdb/ldb_modules
parent8bceed449d7332a5f860000b8c1b53ed8ccf72fa (diff)
downloadsamba-4172e09c5395b7004ada0d4a9e786bba6c159bc9.tar.gz
samba-4172e09c5395b7004ada0d4a9e786bba6c159bc9.tar.bz2
samba-4172e09c5395b7004ada0d4a9e786bba6c159bc9.zip
Fix DRSUAPI replication test - NET-API-BECOME-DC.
The main change here is to work with the current module stack, replacing only the objectGUID module, rather than a number of modules. However, two changes were key: - Fixing a typo search_req->handle -> change_req->handle - Allowing an error of NO_SUCH_OBJECT - it is quite valid for the object not to exist when being replicated in. Other small changes were required to the ejs provision to match changes in that code. Andrew Bartlett (This used to be commit 7b87a58502a052de391f4e1c56ac78a8d35b4e34)
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c140
1 files changed, 14 insertions, 126 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 5a3cc4bef4..a21cf250cb 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -240,12 +240,9 @@ static int replmd_prepare_originating(struct ldb_module *module, struct ldb_requ
struct ldb_dn *dn, const char *fn_name,
int (*fn)(struct ldb_module *,
struct ldb_request *,
- const struct dsdb_schema *,
- const struct dsdb_control_current_partition *))
+ const struct dsdb_schema *))
{
const struct dsdb_schema *schema;
- const struct ldb_control *partition_ctrl;
- const struct dsdb_control_current_partition *partition;
/* do not manipulate our control entries */
if (ldb_dn_is_special(dn)) {
@@ -260,46 +257,16 @@ static int replmd_prepare_originating(struct ldb_module *module, struct ldb_requ
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID);
- if (!partition_ctrl) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
- "%s: no current partition control found",
- fn_name);
- return LDB_ERR_CONSTRAINT_VIOLATION;
- }
-
- partition = talloc_get_type(partition_ctrl->data,
- struct dsdb_control_current_partition);
- if (!partition) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
- "%s: current partition control contains invalid data",
- fn_name);
- return LDB_ERR_CONSTRAINT_VIOLATION;
- }
-
- if (partition->version != DSDB_CONTROL_CURRENT_PARTITION_VERSION) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
- "%s: current partition control contains invalid version [%u != %u]\n",
- fn_name, partition->version, DSDB_CONTROL_CURRENT_PARTITION_VERSION);
- return LDB_ERR_CONSTRAINT_VIOLATION;
- }
-
- return fn(module, req, schema, partition);
+ return fn(module, req, schema);
}
static int replmd_add_originating(struct ldb_module *module,
struct ldb_request *req,
- const struct dsdb_schema *schema,
- const struct dsdb_control_current_partition *partition)
+ const struct dsdb_schema *schema)
{
enum ndr_err_code ndr_err;
struct ldb_request *down_req;
struct ldb_message *msg;
- uint32_t instance_type;
- struct ldb_dn *new_dn;
- const char *rdn_name;
- const char *rdn_name_upper;
- const struct ldb_val *rdn_value = NULL;
const struct dsdb_attribute *rdn_attr = NULL;
struct GUID guid;
struct ldb_val guid_value;
@@ -321,12 +288,6 @@ static int replmd_add_originating(struct ldb_module *module,
return LDB_ERR_UNWILLING_TO_PERFORM;
}
- if (ldb_msg_find_element(req->op.add.message, "instanceType")) {
- ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
- "replmd_add_originating: it's not allowed to add an object with instanceType\n");
- return LDB_ERR_UNWILLING_TO_PERFORM;
- }
-
/* Get a sequence number from the backend */
ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num);
if (ret != LDB_SUCCESS) {
@@ -368,32 +329,9 @@ static int replmd_add_originating(struct ldb_module *module,
return LDB_ERR_OPERATIONS_ERROR;
}
- /*
- * get details of the rdn name
- */
- rdn_name = ldb_dn_get_rdn_name(msg->dn);
- if (!rdn_name) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- rdn_attr = dsdb_attribute_by_lDAPDisplayName(schema, rdn_name);
- if (!rdn_attr) {
- talloc_free(down_req);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- rdn_value = ldb_dn_get_rdn_val(msg->dn);
- if (!rdn_value) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
/*
* remove autogenerated attributes
*/
- ldb_msg_remove_attr(msg, rdn_name);
- ldb_msg_remove_attr(msg, "name");
ldb_msg_remove_attr(msg, "whenCreated");
ldb_msg_remove_attr(msg, "whenChanged");
ldb_msg_remove_attr(msg, "uSNCreated");
@@ -401,69 +339,14 @@ static int replmd_add_originating(struct ldb_module *module,
ldb_msg_remove_attr(msg, "replPropertyMetaData");
/*
- * TODO: construct a new DN out of:
- * - the parent DN
- * - the upper case of rdn_attr->LDAPDisplayName
- * - rdn_value
- */
- new_dn = ldb_dn_copy(msg, msg->dn);
- if (!new_dn) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- rdn_name_upper = strupper_talloc(msg, rdn_attr->lDAPDisplayName);
- if (!rdn_name_upper) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ret = ldb_dn_set_component(new_dn, 0, rdn_name_upper, *rdn_value);
- if (ret != LDB_SUCCESS) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- msg->dn = new_dn;
-
- /*
- * TODO: calculate correct instance type
- */
- instance_type = INSTANCE_TYPE_WRITE;
- if (ldb_dn_compare(partition->dn, msg->dn) == 0) {
- instance_type |= INSTANCE_TYPE_IS_NC_HEAD;
- if (ldb_dn_compare(msg->dn, samdb_base_dn(module->ldb)) != 0) {
- instance_type |= INSTANCE_TYPE_NC_ABOVE;
- }
- }
-
- /*
* readd replicated attributes
*/
- ret = ldb_msg_add_value(msg, rdn_attr->lDAPDisplayName, rdn_value, NULL);
- if (ret != LDB_SUCCESS) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
- ret = ldb_msg_add_value(msg, "name", rdn_value, NULL);
- if (ret != LDB_SUCCESS) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
ret = ldb_msg_add_string(msg, "whenCreated", time_str);
if (ret != LDB_SUCCESS) {
talloc_free(down_req);
ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type);
- if (ret != LDB_SUCCESS) {
- talloc_free(down_req);
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
/* build the replication meta_data */
ZERO_STRUCT(nmd);
@@ -598,8 +481,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
static int replmd_modify_originating(struct ldb_module *module,
struct ldb_request *req,
- const struct dsdb_schema *schema,
- const struct dsdb_control_current_partition *partition)
+ const struct dsdb_schema *schema)
{
struct ldb_request *down_req;
struct ldb_message *msg;
@@ -806,10 +688,16 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar)
return ldb_next_request(ar->module, ar->sub.change_req);
#else
ret = ldb_next_request(ar->module, ar->sub.change_req);
- if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret);
+ if (ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(ar->module->ldb, "Failed to add replicated object %s: %s", ldb_dn_get_linearized(ar->sub.change_req->op.add.message->dn),
+ ldb_errstring(ar->module->ldb));
+ return replmd_replicated_request_error(ar, ret);
+ }
- ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL);
+ ar->sub.change_ret = ldb_wait(ar->sub.change_req->handle, LDB_WAIT_ALL);
if (ar->sub.change_ret != LDB_SUCCESS) {
+ ldb_asprintf_errstring(ar->module->ldb, "Failed while waiting on add replicated object %s: %s", ldb_dn_get_linearized(ar->sub.change_req->op.add.message->dn),
+ ldb_errstring(ar->module->ldb));
return replmd_replicated_request_error(ar, ar->sub.change_ret);
}
@@ -1053,7 +941,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar)
ret = ldb_next_request(ar->module, ar->sub.change_req);
if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret);
- ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL);
+ ar->sub.change_ret = ldb_wait(ar->sub.change_req->handle, LDB_WAIT_ALL);
if (ar->sub.change_ret != LDB_SUCCESS) {
return replmd_replicated_request_error(ar, ar->sub.change_ret);
}
@@ -1137,7 +1025,7 @@ static int replmd_replicated_apply_search(struct replmd_replicated_request *ar)
if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret);
ar->sub.search_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL);
- if (ar->sub.search_ret != LDB_SUCCESS) {
+ if (ar->sub.search_ret != LDB_SUCCESS && ar->sub.search_ret != LDB_ERR_NO_SUCH_OBJECT) {
return replmd_replicated_request_error(ar, ar->sub.search_ret);
}
if (ar->sub.search_msg) {