summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-27 00:16:02 +0200
committerStefan Metzmacher <metze@samba.org>2009-11-06 14:05:45 +0100
commit9da33436e4de8c092905b3a98584c480592bddc6 (patch)
treecc3d669889d35da0f058e404c0cd0ec7c2138655 /source4/dsdb/schema
parent5381d8d157e90ae0e6058a19c2486377221ef3f6 (diff)
downloadsamba-9da33436e4de8c092905b3a98584c480592bddc6.tar.gz
samba-9da33436e4de8c092905b3a98584c480592bddc6.tar.bz2
samba-9da33436e4de8c092905b3a98584c480592bddc6.zip
s4/drs: refactor dsdb_load_oid_mappings_ldb() to use _dsdb_prefixmap_from_ldb_val()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb/schema')
-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;
}