diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2010-04-22 17:59:22 +0300 |
---|---|---|
committer | Kamen Mazdrashki <kamenim@samba.org> | 2010-04-29 04:54:06 +0300 |
commit | e41eac96afb1d6d465faeb1e4e9a669cff1b8bc1 (patch) | |
tree | 6a1cfe0cbb2b6e868f4397577cecae59df8dc101 /source4/dsdb/schema | |
parent | 546a727bd326464c6fac3c6454e4e98314e0e75a (diff) | |
download | samba-e41eac96afb1d6d465faeb1e4e9a669cff1b8bc1.tar.gz samba-e41eac96afb1d6d465faeb1e4e9a669cff1b8bc1.tar.bz2 samba-e41eac96afb1d6d465faeb1e4e9a669cff1b8bc1.zip |
s4/samldb: Create initial schemaInfo value if it doesn't exists yet
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r-- | source4/dsdb/schema/schema_info_attr.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/source4/dsdb/schema/schema_info_attr.c b/source4/dsdb/schema/schema_info_attr.c index 60722eea52..44a12ad629 100644 --- a/source4/dsdb/schema/schema_info_attr.c +++ b/source4/dsdb/schema/schema_info_attr.c @@ -30,6 +30,24 @@ /** + * Creates and initializes new dsdb_schema_info value. + * Initial schemaInfo values is with: + * revision = 0 + * invocationId = GUID_ZERO + */ +WERROR dsdb_schema_info_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info) +{ + struct dsdb_schema_info *schema_info; + + schema_info = talloc_zero(mem_ctx, struct dsdb_schema_info); + W_ERROR_HAVE_NO_MEMORY(schema_info); + + *_schema_info = schema_info; + + return WERR_OK; +} + +/** * Creates and initializes new dsdb_schema_info blob value. * Initial schemaInfo values is with: * revision = 0 @@ -391,20 +409,25 @@ WERROR dsdb_module_schema_info_update(struct ldb_module *ldb_module, const struct GUID *invocation_id; struct dsdb_schema_info *schema_info; - TALLOC_CTX *mem_ctx = talloc_new(schema); - W_ERROR_HAVE_NO_MEMORY(mem_ctx); + TALLOC_CTX *temp_ctx = talloc_new(schema); + W_ERROR_HAVE_NO_MEMORY(temp_ctx); invocation_id = samdb_ntds_invocation_id(ldb_module_get_ctx(ldb_module)); if (!invocation_id) { return WERR_INTERNAL_DB_CORRUPTION; } - werr = dsdb_module_schema_info_read(ldb_module, dsdb_flags, - mem_ctx, &schema_info); + /* read serialized schemaInfo from LDB */ + werr = dsdb_module_schema_info_read(ldb_module, dsdb_flags, temp_ctx, &schema_info); + if (W_ERROR_EQUAL(werr, WERR_DS_NO_ATTRIBUTE_OR_VALUE)) { + /* make default value in case + * we have no schemaInfo value yet */ + werr = dsdb_schema_info_new(temp_ctx, &schema_info); + } if (!W_ERROR_IS_OK(werr)) { DEBUG(0,("dsdb_module_schema_info_update: failed to reload schemaInfo - %s\n", win_errstr(werr))); - talloc_free(mem_ctx); + talloc_free(temp_ctx); return werr; } @@ -416,7 +439,7 @@ WERROR dsdb_module_schema_info_update(struct ldb_module *ldb_module, if (!W_ERROR_IS_OK(werr)) { DEBUG(0,("dsdb_module_schema_info_update: failed to save schemaInfo - %s\n", win_errstr(werr))); - talloc_free(mem_ctx); + talloc_free(temp_ctx); return werr; } @@ -427,6 +450,6 @@ WERROR dsdb_module_schema_info_update(struct ldb_module *ldb_module, schema->schema_info = talloc_steal(schema, schema_info); */ - talloc_free(mem_ctx); + talloc_free(temp_ctx); return WERR_OK; } |