uint32_t linked_attributes_count;
struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
+ struct dsdb_extended_replicated_objects *objects;
bool more_data = false;
WERROR status;
return;
}
+ status = dsdb_extended_replicated_objects_convert(service->samdb,
+ partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ &rf1,
+ uptodateness_vector,
+ &drsuapi->gensec_skey,
+ st, &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));
+ return;
+ }
+
status = dsdb_extended_replicated_objects_commit(service->samdb,
- partition->nc.dn,
- mapping_ctr,
- object_count,
- first_object,
- linked_attributes_count,
- linked_attributes,
- &rf1,
- uptodateness_vector,
- &drsuapi->gensec_skey,
- st, NULL,
+ objects,
&st->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));
return WERR_OK;
}
-WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb,
- const char *partition_dn,
- const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr,
- uint32_t object_count,
- const struct drsuapi_DsReplicaObjectListItemEx *first_object,
- uint32_t linked_attributes_count,
- const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes,
- const struct repsFromTo1 *source_dsa,
- const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector,
- const DATA_BLOB *gensec_skey,
- TALLOC_CTX *mem_ctx,
- struct dsdb_extended_replicated_objects **_out,
- uint64_t *notify_uSN)
+WERROR dsdb_extended_replicated_objects_convert(struct ldb_context *ldb,
+ const char *partition_dn,
+ const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr,
+ uint32_t object_count,
+ const struct drsuapi_DsReplicaObjectListItemEx *first_object,
+ uint32_t linked_attributes_count,
+ const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes,
+ const struct repsFromTo1 *source_dsa,
+ const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector,
+ const DATA_BLOB *gensec_skey,
+ TALLOC_CTX *mem_ctx,
+ struct dsdb_extended_replicated_objects **objects)
{
WERROR status;
const struct dsdb_schema *schema;
struct dsdb_extended_replicated_objects *out;
- struct ldb_result *ext_res;
const struct drsuapi_DsReplicaObjectListItemEx *cur;
uint32_t i;
- int ret;
- uint64_t seq_num1, seq_num2;
schema = dsdb_get_schema(ldb);
if (!schema) {
return WERR_FOOBAR;
}
+ *objects = out;
+ return WERR_OK;
+}
+
+WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb,
+ struct dsdb_extended_replicated_objects *objects,
+ uint64_t *notify_uSN)
+{
+ struct ldb_result *ext_res;
+ int ret;
+ uint64_t seq_num1, seq_num2;
+
/* TODO: handle linked attributes */
/* wrap the extended operation in a transaction
ret = ldb_transaction_start(ldb);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ " Failed to start transaction\n"));
- talloc_free(out);
return WERR_FOOBAR;
}
- ret = dsdb_load_partition_usn(ldb, out->partition_dn, &seq_num1);
+ ret = dsdb_load_partition_usn(ldb, objects->partition_dn, &seq_num1);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ " Failed to load partition uSN\n"));
- talloc_free(out);
ldb_transaction_cancel(ldb);
return WERR_FOOBAR;
}
- ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, out, &ext_res);
+ ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, objects, &ext_res);
if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to apply records: %s: %s\n",
ldb_errstring(ldb), ldb_strerror(ret)));
- talloc_free(out);
ldb_transaction_cancel(ldb);
return WERR_FOOBAR;
}
ret = ldb_transaction_prepare_commit(ldb);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ " Failed to prepare commit of transaction\n"));
- talloc_free(out);
return WERR_FOOBAR;
}
- ret = dsdb_load_partition_usn(ldb, out->partition_dn, &seq_num2);
+ ret = dsdb_load_partition_usn(ldb, objects->partition_dn, &seq_num2);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ " Failed to load partition uSN\n"));
- talloc_free(out);
ldb_transaction_cancel(ldb);
return WERR_FOOBAR;
}
ret = ldb_transaction_commit(ldb);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ " Failed to commit transaction\n"));
- talloc_free(out);
return WERR_FOOBAR;
}
DEBUG(2,("Replicated %u objects (%u linked attributes) for %s\n",
- out->num_objects, out->linked_attributes_count,
- ldb_dn_get_linearized(out->partition_dn)));
+ objects->num_objects, objects->linked_attributes_count,
+ ldb_dn_get_linearized(objects->partition_dn)));
-
- if (_out) {
- *_out = out;
- } else {
- talloc_free(out);
- }
-
return WERR_OK;
}
if (!W_ERROR_IS_OK(status)) {
return werror_to_ntstatus(status);
}
-
DLIST_ADD_END(s->self_made_schema->classes, sc, struct dsdb_class *);
}
}
return NT_STATUS_FOOBAR;
}
/* we don't want to access the self made schema anymore */
+ s->schema = s->self_made_schema;
s->self_made_schema = NULL;
- s->schema = dsdb_get_schema(s->ldb);
- status = dsdb_extended_replicated_objects_commit(s->ldb,
- c->partition->nc.dn,
- mapping_ctr,
- object_count,
- first_object,
- linked_attributes_count,
- linked_attributes,
- s_dsa,
- uptodateness_vector,
- c->gensec_skey,
- s, &objs, &seq_num);
+ /* Now convert the schema elements again, using the schema we just imported */
+ status = dsdb_extended_replicated_objects_convert(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
if (!W_ERROR_IS_OK(status)) {
DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
return werror_to_ntstatus(status);
}
}
+ status = dsdb_extended_replicated_objects_commit(s->ldb, objs, &seq_num);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
+
msg = ldb_msg_new(objs);
NT_STATUS_HAVE_NO_MEMORY(msg);
msg->dn = objs->partition_dn;
}
- status = dsdb_extended_replicated_objects_commit(s->ldb,
- c->partition->nc.dn,
- mapping_ctr,
- object_count,
- first_object,
- linked_attributes_count,
- linked_attributes,
- s_dsa,
- uptodateness_vector,
- c->gensec_skey,
- s, &objs, &seq_num);
+ status = dsdb_extended_replicated_objects_convert(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status)));
return werror_to_ntstatus(status);
}
NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
}
}
+ status = dsdb_extended_replicated_objects_commit(s->ldb,
+ objs, &seq_num);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
+
talloc_free(s_dsa);
talloc_free(objs);
s->self_made_schema = NULL;
s->schema = dsdb_get_schema(s->ldb);
- status = dsdb_extended_replicated_objects_commit(s->ldb,
- c->partition->nc.dn,
- mapping_ctr,
- object_count,
- first_object,
- linked_attributes_count,
- linked_attributes,
- s_dsa,
- uptodateness_vector,
- c->gensec_skey,
- s, &objs, &seq_num);
+ status = dsdb_extended_replicated_objects_convert(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status)));
return werror_to_ntstatus(status);
}
}
}
+ status = dsdb_extended_replicated_objects_commit(s->ldb,
+ objs, &seq_num);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
+
msg = ldb_msg_new(objs);
NT_STATUS_HAVE_NO_MEMORY(msg);
msg->dn = objs->partition_dn;
c->partition->nc.dn, object_count, linked_attributes_count));
}
- status = dsdb_extended_replicated_objects_commit(s->ldb,
- c->partition->nc.dn,
- mapping_ctr,
- object_count,
- first_object,
- linked_attributes_count,
- linked_attributes,
- s_dsa,
- uptodateness_vector,
- c->gensec_skey,
- s, &objs, &seq_num);
+ status = dsdb_extended_replicated_objects_convert(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status)));
return werror_to_ntstatus(status);
}
NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
}
}
+ status = dsdb_extended_replicated_objects_commit(s->ldb, objs, &seq_num);
talloc_free(s_dsa);
talloc_free(objs);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
for (i=0; i < linked_attributes_count; i++) {
const struct dsdb_attribute *sa;
status = libnet_BecomeDC(s->ctx, s, &b);
if (!NT_STATUS_IS_OK(status)) {
- printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));
+ printf("libnet_BecomeDC() failed - %s %s\n", nt_errstr(status), b.out.error_string);
ret = false;
goto cleanup;
}
status = libnet_UnbecomeDC(s->ctx, s, &u);
if (!NT_STATUS_IS_OK(status)) {
- printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status));
+ printf("libnet_UnbecomeDC() failed - %s %s\n", nt_errstr(status), u.out.error_string);
ret = false;
}