diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2010-04-09 10:48:20 +0300 |
---|---|---|
committer | Kamen Mazdrashki <kamenim@samba.org> | 2010-04-09 12:21:34 +0300 |
commit | 8149094eddebd9a0e8b7c123c2ed54d00164bb26 (patch) | |
tree | dfe5731e4331d76fe88c39a0243e77e69a083ff2 /source4/dsdb/schema | |
parent | 4ba2ac073d7a7859ab73f8b7f40d630ddbff8687 (diff) | |
download | samba-8149094eddebd9a0e8b7c123c2ed54d00164bb26.tar.gz samba-8149094eddebd9a0e8b7c123c2ed54d00164bb26.tar.bz2 samba-8149094eddebd9a0e8b7c123c2ed54d00164bb26.zip |
s4/dsdb: Set schemaInfo attribute value during provisioning
After provisioning new Forest, schemaInfo should be set
to a value with revision=1 and current invocation_id
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r-- | source4/dsdb/schema/schema_info_attr.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_info_attr.c b/source4/dsdb/schema/schema_info_attr.c index ea4d066ff1..bb89be1172 100644 --- a/source4/dsdb/schema/schema_info_attr.c +++ b/source4/dsdb/schema/schema_info_attr.c @@ -355,6 +355,55 @@ WERROR dsdb_schema_info_create(struct ldb_context *ldb, bool check_invocation_id /** + * + * @param ldb + * @param schema + * @return + */ +WERROR dsdb_schema_info_reset(struct ldb_context *ldb, struct dsdb_schema *schema) +{ + int ldb_err; + WERROR werr; + DATA_BLOB blob; + struct dsdb_schema_info *schema_info; + struct ldb_message *msg; + TALLOC_CTX *temp_ctx; + + temp_ctx = talloc_new(ldb); + W_ERROR_HAVE_NO_MEMORY(temp_ctx); + + /* create default schemaInfo value */ + werr = dsdb_schema_info_create(ldb, true, temp_ctx, &schema_info); + W_ERROR_NOT_OK_GOTO(werr, DONE); + + /* serialize schemaInfo to be stored in LDB and schema cache */ + werr = dsdb_blob_from_schema_info(schema_info, temp_ctx, &blob); + W_ERROR_NOT_OK_GOTO(werr, DONE); + + /* store initial schemaInfo in DB */ + werr = _dsdb_schema_info_write_prepare(ldb, &blob, temp_ctx, &msg); + W_ERROR_NOT_OK_GOTO(werr, DONE); + + ldb_err = dsdb_modify(ldb, msg, DSDB_MODIFY_PERMISSIVE); + if (ldb_err != 0) { + DEBUG(0,("dsdb_module_schema_info_blob_write: dsdb_replace failed: %s (%s)\n", + ldb_strerror(ldb_err), + ldb_errstring(ldb))); + werr = WERR_INTERNAL_DB_ERROR; + goto DONE; + } + + /* update dsdb_schema cache */ + talloc_free(discard_const(schema->schema_info)); + schema->schema_info = data_blob_hex_string_upper(schema, &blob); + +DONE: + talloc_free(temp_ctx); + return werr; +} + + +/** * Increments schemaInfo revision and save it to DB * setting our invocationID in the process * NOTE: this function should be called in a transaction |