summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/schema/schema_init.c62
1 files changed, 29 insertions, 33 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 615e1d4d3d..5b0ad5d383 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -105,50 +105,46 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema,
const struct ldb_val *schemaInfo)
{
WERROR status;
- enum ndr_err_code ndr_err;
- struct prefixMapBlob pfm;
- DATA_BLOB schema_info_blob;
+ const char *schema_info;
+ struct dsdb_schema_prefixmap *pfm;
+ TALLOC_CTX *mem_ctx;
- TALLOC_CTX *mem_ctx = talloc_new(schema);
- W_ERROR_HAVE_NO_MEMORY(mem_ctx);
-
- ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
- talloc_free(mem_ctx);
- return ntstatus_to_werror(nt_status);
+ /* verify input params */
+ if (schemaInfo->length != 21) {
+ return WERR_INVALID_PARAMETER;
}
-
- if (pfm.version != PREFIX_MAP_VERSION_DSDB) {
- talloc_free(mem_ctx);
- return WERR_FOOBAR;
+ if (schemaInfo->data[0] != 0xFF) {
+ return WERR_INVALID_PARAMETER;
}
- if (schemaInfo->length != 21 && schemaInfo->data[0] == 0xFF) {
+ mem_ctx = talloc_new(schema);
+ W_ERROR_HAVE_NO_MEMORY(mem_ctx);
+
+ /* fetch prefixMap */
+ status = _dsdb_prefixmap_from_ldb_val(prefixMap,
+ schema->iconv_convenience,
+ mem_ctx, &pfm);
+ W_ERROR_NOT_OK_RETURN(status);
+
+ /* decode schema_info */
+ schema_info = hex_encode_talloc(mem_ctx,
+ schemaInfo->data,
+ schemaInfo->length);
+ if (!schema_info) {
talloc_free(mem_ctx);
- return WERR_FOOBAR;
+ return WERR_NOMEM;
}
- /* append the schema info as last element */
- pfm.ctr.dsdb.num_mappings++;
- pfm.ctr.dsdb.mappings = talloc_realloc(mem_ctx, pfm.ctr.dsdb.mappings,
- struct drsuapi_DsReplicaOIDMapping,
- pfm.ctr.dsdb.num_mappings);
- W_ERROR_HAVE_NO_MEMORY(pfm.ctr.dsdb.mappings);
-
- schema_info_blob = data_blob_dup_talloc(pfm.ctr.dsdb.mappings, schemaInfo);
- W_ERROR_HAVE_NO_MEMORY(schema_info_blob.data);
+ /* store prefixMap and schema_info into cached Schema */
+ talloc_free(schema->prefixmap);
+ schema->prefixmap = talloc_steal(schema, pfm);
- pfm.ctr.dsdb.mappings[pfm.ctr.dsdb.num_mappings - 1].id_prefix = 0;
- pfm.ctr.dsdb.mappings[pfm.ctr.dsdb.num_mappings - 1].oid.length = schemaInfo->length;
- pfm.ctr.dsdb.mappings[pfm.ctr.dsdb.num_mappings - 1].oid.binary_oid = schema_info_blob.data;
+ talloc_free(discard_const(schema->schema_info));
+ schema->schema_info = talloc_steal(schema, schema_info);
- /* call the drsuapi version */
- status = dsdb_load_prefixmap_from_drsuapi(schema, &pfm.ctr.dsdb);
+ /* clean up locally allocated mem */
talloc_free(mem_ctx);
- W_ERROR_NOT_OK_RETURN(status);
-
return WERR_OK;
}