summaryrefslogtreecommitdiff
path: root/source4/libnet/libnet_vampire.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-06-10 21:33:45 +1000
committerAndrew Bartlett <abartlet@samba.org>2010-06-15 10:51:34 +1000
commit7c60ac97bf72aa08df39aa9695607270e39931c5 (patch)
tree1d15467d8a5b584b1eb3a8c4715bb404a68a639b /source4/libnet/libnet_vampire.c
parent9e28ceda96a0c76752af851db4ccba86c010ed67 (diff)
downloadsamba-7c60ac97bf72aa08df39aa9695607270e39931c5.tar.gz
samba-7c60ac97bf72aa08df39aa9695607270e39931c5.tar.bz2
samba-7c60ac97bf72aa08df39aa9695607270e39931c5.zip
s4:provision Allow a specific prefix map to be loaded into a new schema provision
This allows the prefixMap from a DRS server to be used when loading the schema from the local files. This helps us then import other schema with this map in place. Andrew Bartlett Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Diffstat (limited to 'source4/libnet/libnet_vampire.c')
-rw-r--r--source4/libnet/libnet_vampire.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c
index 3b0b5a78b3..84fe2944e0 100644
--- a/source4/libnet/libnet_vampire.c
+++ b/source4/libnet/libnet_vampire.c
@@ -198,6 +198,7 @@ static NTSTATUS libnet_vampire_cb_apply_schema(struct libnet_vampire_cb_state *s
struct dsdb_extended_replicated_objects *schema_objs_1, *schema_objs_2;
struct repsFromTo1 *s_dsa;
char *tmp_dns_name;
+ struct ldb_context *schema_ldb;
struct ldb_message *msg;
struct ldb_val prefixMap_val;
struct ldb_message_element *prefixMap_el;
@@ -252,6 +253,20 @@ static NTSTATUS libnet_vampire_cb_apply_schema(struct libnet_vampire_cb_state *s
NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
s_dsa->other_info->dns_name = tmp_dns_name;
+ schema_ldb = provision_get_schema(s, s->lp_ctx, &s->prefixmap_blob);
+ if (!schema_ldb) {
+ DEBUG(0,("Failed to re-load from local provision using remote prefixMap. Will continue with local prefixMap\n"));
+ s->provision_schema = dsdb_get_schema(s->ldb, s);
+ } else {
+ s->provision_schema = dsdb_get_schema(schema_ldb, s);
+ ret = dsdb_reference_schema(s->ldb, s->provision_schema, false);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(0,("Failed to attach schema from local provision using remote prefixMap."));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ talloc_free(schema_ldb);
+ }
+
s->provision_schema->relax_OID_conversions = true;
/* Now convert the schema elements again, using the schema we just imported */
@@ -425,11 +440,19 @@ NTSTATUS libnet_vampire_cb_schema_chunk(void *private_data,
if (!s->schema) {
WERROR werr;
+ struct drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr_without_schema_info;
/* Put the DRS prefixmap aside for the schema we are
* about to load in the provision, and into the one we
* are making with the help of DRS */
- werr = dsdb_get_drsuapi_prefixmap_as_blob(mapping_ctr, s, &s->prefixmap_blob);
+ mapping_ctr_without_schema_info = *mapping_ctr;
+
+ /* This strips off the 0xFF schema info from the end,
+ * because we don't want it in the blob */
+ if (mapping_ctr_without_schema_info.num_mappings > 0) {
+ mapping_ctr_without_schema_info.num_mappings--;
+ }
+ werr = dsdb_get_drsuapi_prefixmap_as_blob(&mapping_ctr_without_schema_info, s, &s->prefixmap_blob);
if (!W_ERROR_IS_OK(werr)) {
return werror_to_ntstatus(werr);
}