[SCM] Samba Shared Repository - branch v4-0-test updated -
release-4-0-0alpha5-165-g2f06fbe
Stefan Metzmacher
metze at samba.org
Sat Jul 26 19:46:09 GMT 2008
The branch, v4-0-test has been updated
via 2f06fbe06be2e1b77ea013ddba853ce819e58e88 (commit)
via c92eb8b776c17f12622837daeb1786862f380269 (commit)
via 34ea9d4a0b1270a27412bf939d7e897a5d68d0a6 (commit)
from 131a1cfdc9a1228d9263c77bcd31b05d2946fd50 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test
- Log -----------------------------------------------------------------
commit 2f06fbe06be2e1b77ea013ddba853ce819e58e88
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu Jul 24 10:00:20 2008 +0200
dsdb: add a comment about the parameter to DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID
metze
commit c92eb8b776c17f12622837daeb1786862f380269
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu Jul 24 09:55:53 2008 +0200
dsdb/schema: make more clear where we create the value for the new prefix mapping
metze
commit 34ea9d4a0b1270a27412bf939d7e897a5d68d0a6
Author: Stefan Metzmacher <metze at samba.org>
Date: Thu Jul 24 09:53:29 2008 +0200
dsdb/schema: dsdb_write_prefixes_to_ldb() should do the reverse of dsdb_read_prefixes_to_ldb()
metze
-----------------------------------------------------------------------
Summary of changes:
source/dsdb/samdb/samdb.h | 4 ++
source/dsdb/schema/schema_init.c | 102 ++++++++++++++++++-------------------
2 files changed, 54 insertions(+), 52 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/dsdb/samdb/samdb.h b/source/dsdb/samdb/samdb.h
index b8a3e16..3e92671 100644
--- a/source/dsdb/samdb/samdb.h
+++ b/source/dsdb/samdb/samdb.h
@@ -90,6 +90,10 @@ struct dsdb_pdc_fsmo {
struct ldb_dn *master_dn;
};
+/*
+ * the schema_dn is passed as struct ldb_dn in
+ * req->op.extended.data
+ */
#define DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID "1.3.6.1.4.1.7165.4.4.2"
#endif /* __SAMDB_H__ */
diff --git a/source/dsdb/schema/schema_init.c b/source/dsdb/schema/schema_init.c
index 706c8e2..9b89594 100644
--- a/source/dsdb/schema/schema_init.c
+++ b/source/dsdb/schema/schema_init.c
@@ -302,7 +302,6 @@ WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *s
WERROR status;
uint32_t num_prefixes;
struct dsdb_schema_oid_prefix *prefixes;
- struct ldb_val ndr_blob;
TALLOC_CTX *mem_ctx;
uint32_t out;
@@ -312,7 +311,8 @@ WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *s
/* Read prefixes from disk*/
status = dsdb_read_prefixes_from_ldb( mem_ctx, ldb, &num_prefixes, &prefixes );
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("dsdb_create_prefix_mapping: dsdb_read_prefixes_from_ldb failed\n"));
+ DEBUG(0,("dsdb_create_prefix_mapping: dsdb_read_prefixes_from_ldb: %s\n",
+ win_errstr(status)));
talloc_free(mem_ctx);
return status;
}
@@ -323,27 +323,28 @@ WERROR dsdb_create_prefix_mapping(struct ldb_context *ldb, struct dsdb_schema *s
/* prefix found*/
talloc_free(mem_ctx);
return status;
- }
- /* Update prefix map in ldb*/
- /* Update the prefixes */
- status = dsdb_prefix_map_update(mem_ctx, &num_prefixes, &prefixes, full_oid);
- if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("dsdb_create_prefix_mapping: dsdb_prefix_map_update failed\n"));
+ } else if (!W_ERROR_EQUAL(WERR_DS_NO_MSDS_INTID, status)) {
+ /* error */
+ DEBUG(0,("dsdb_create_prefix_mapping: dsdb_find_prefix_for_oid: %s\n",
+ win_errstr(status)));
talloc_free(mem_ctx);
return status;
}
- /* Convert prefixes in ndr blob*/
- status = dsdb_write_prefixes_to_ndr( mem_ctx, ldb, num_prefixes, prefixes, &ndr_blob );
+
+ /* Create the new mapping for the prefix of full_oid */
+ status = dsdb_prefix_map_update(mem_ctx, &num_prefixes, &prefixes, full_oid);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("dsdb_create_prefix_mapping: dsdb_write_prefixes_to_ndr failed\n"));
+ DEBUG(0,("dsdb_create_prefix_mapping: dsdb_prefix_map_update: %s\n",
+ win_errstr(status)));
talloc_free(mem_ctx);
return status;
}
/* Update prefixMap in ldb*/
- status = dsdb_write_prefixes_to_ldb( mem_ctx, ldb, &ndr_blob );
+ status = dsdb_write_prefixes_to_ldb(mem_ctx, ldb, num_prefixes, prefixes);
if (!W_ERROR_IS_OK(status)) {
- DEBUG(0,("dsdb_create_prefix_mapping: dsdb_write_prefixes_to_ldb failed\n"));
+ DEBUG(0,("dsdb_create_prefix_mapping: dsdb_write_prefixes_to_ldb: %s\n",
+ win_errstr(status)));
talloc_free(mem_ctx);
return status;
}
@@ -360,6 +361,12 @@ WERROR dsdb_prefix_map_update(TALLOC_CTX *mem_ctx, uint32_t *num_prefixes, struc
new_num_prefixes = *num_prefixes + 1;
index_new_prefix = *num_prefixes;
+
+ /*
+ * this is the algorithm we use to create new mappings for now
+ *
+ * TODO: find what algorithm windows use
+ */
new_entry_id = (*num_prefixes)<<16;
/* Extract the prefix from the oid*/
@@ -439,11 +446,17 @@ WERROR dsdb_find_prefix_for_oid(uint32_t num_prefixes, const struct dsdb_schema_
return WERR_DS_NO_MSDS_INTID;
}
-WERROR dsdb_write_prefixes_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, struct ldb_val *ndr_blob)
+WERROR dsdb_write_prefixes_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
+ uint32_t num_prefixes,
+ const struct dsdb_schema_oid_prefix *prefixes)
{
struct ldb_message msg;
struct ldb_dn *schema_dn;
struct ldb_message_element el;
+ struct prefixMapBlob pm;
+ struct ldb_val ndr_blob;
+ enum ndr_err_code ndr_err;
+ uint32_t i;
int ret;
schema_dn = samdb_schema_dn(ldb);
@@ -451,9 +464,31 @@ WERROR dsdb_write_prefixes_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
DEBUG(0,("dsdb_write_prefixes_to_ldb: no schema dn present\n"));
return WERR_FOOBAR;
}
+
+ pm.version = PREFIX_MAP_VERSION_DSDB;
+ pm.ctr.dsdb.num_mappings = num_prefixes;
+ pm.ctr.dsdb.mappings = talloc_array(mem_ctx,
+ struct drsuapi_DsReplicaOIDMapping,
+ pm.ctr.dsdb.num_mappings);
+ if (!pm.ctr.dsdb.mappings) {
+ return WERR_NOMEM;
+ }
+
+ for (i=0; i < num_prefixes; i++) {
+ pm.ctr.dsdb.mappings[i].id_prefix = prefixes[i].id>>16;
+ pm.ctr.dsdb.mappings[i].oid.oid = talloc_strdup(pm.ctr.dsdb.mappings, prefixes[i].oid);
+ }
+
+ ndr_err = ndr_push_struct_blob(&ndr_blob, ldb,
+ lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
+ &pm,
+ (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return WERR_FOOBAR;
+ }
el.num_values = 1;
- el.values = ndr_blob;
+ el.values = &ndr_blob;
el.flags = LDB_FLAG_MOD_REPLACE;
el.name = talloc_strdup(mem_ctx, "prefixMap");
@@ -541,43 +576,6 @@ WERROR dsdb_read_prefixes_from_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
return WERR_OK;
}
-
-WERROR dsdb_write_prefixes_to_ndr(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, uint32_t num_prefixes, const struct dsdb_schema_oid_prefix *prefixes, struct ldb_val *out)
-{
- struct prefixMapBlob *blob;
- enum ndr_err_code ndr_err;
- uint32_t i;
-
- blob = talloc_zero(mem_ctx, struct prefixMapBlob);
- W_ERROR_HAVE_NO_MEMORY(blob);
-
- blob->version = PREFIX_MAP_VERSION_DSDB;
- blob->ctr.dsdb.num_mappings = num_prefixes;
- blob->ctr.dsdb.mappings = talloc_realloc(blob,
- blob->ctr.dsdb.mappings,
- struct drsuapi_DsReplicaOIDMapping,
- blob->ctr.dsdb.num_mappings);
- if (!blob->ctr.dsdb.mappings) {
- return WERR_NOMEM;
- }
-
- for (i=0; i < num_prefixes; i++) {
- blob->ctr.dsdb.mappings[i].id_prefix = prefixes[i].id>>16;
- blob->ctr.dsdb.mappings[i].oid.oid = talloc_strdup(blob->ctr.dsdb.mappings, prefixes[i].oid);
- }
-
- ndr_err = ndr_push_struct_blob(out, ldb,
- lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
- blob,
- (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- return WERR_FOOBAR;
- }
-
- return WERR_OK;
-}
-
-
#define GET_STRING_LDB(msg, attr, mem_ctx, p, elem, strict) do { \
(p)->elem = samdb_result_string(msg, attr, NULL);\
if (strict && (p)->elem == NULL) { \
--
Samba Shared Repository
More information about the samba-cvs
mailing list