- /* 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, &schema_objs_1);
- if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("Failed to convert objects when trying to import over DRS (1st pass, to create local schema): %s\n", win_errstr(status)));
- return werror_to_ntstatus(status);
+ /* Now convert the schema elements, using the schema we loaded locally */
+ for (i=0, cur = first_object; cur; cur = cur->next_object, i++) {
+ struct dsdb_extended_replicated_object object;
+ TALLOC_CTX *tmp_ctx = talloc_new(s);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ /* Convert the objects into LDB messages using the
+ * provision schema, and either the provision or DRS
+ * prefix map - it should not matter, as these are
+ * just schema objects, so the critical parts. At
+ * most we would mix up the mayContain etc for new
+ * schema classes */
+ status = dsdb_convert_object_ex(s->ldb, s->provision_schema,
+ cur, c->gensec_skey,
+ tmp_ctx, &object);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(1,("Warning: Failed to convert schema object %s into ldb msg\n", cur->object.identifier->dn));
+ } else {
+ /* Convert the schema from ldb_message format
+ * (OIDs as OID strings) into schema, using
+ * the remote prefixMap */
+ status = dsdb_schema_set_el_from_ldb_msg(s->ldb, s->self_made_schema, object.msg);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(1,("Warning: failed to convert object %s into a schema element: %s\n",
+ ldb_dn_get_linearized(object.msg->dn),
+ win_errstr(status)));
+ }
+ }
+ talloc_free(tmp_ctx);
+ }
+
+ /* attach the schema we just brought over DRS to the ldb, so we can use it in dsdb_convert_object_ex below */
+ ret = dsdb_set_schema(s->ldb, s->self_made_schema);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(0,("Failed to attach 1st pass schema from DRS.\n"));
+ return NT_STATUS_FOOBAR;