From 6d439afbf77b15d34310144c473f6600148f7d84 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Tue, 6 Apr 2010 15:17:05 +0300 Subject: [PATCH] s4/samldb: schemaInfo attribute must be updated when adding new Schema object --- source4/dsdb/samdb/ldb_modules/samldb.c | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 24d1450d9cc..3b2d283006f 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -1054,6 +1054,44 @@ static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) return LDB_SUCCESS; } +static int samldb_schema_info_update(struct samldb_ctx *ac) +{ + WERROR werr; + struct ldb_context *ldb; + struct dsdb_schema *schema; + + /* replicated update should always go through */ + if (ldb_request_get_control(ac->req, DSDB_CONTROL_REPLICATED_UPDATE_OID)) { + return LDB_SUCCESS; + } + + /* do not update schemaInfo during provisioning */ + if (ldb_request_get_control(ac->req, LDB_CONTROL_RELAX_OID)) { + return LDB_SUCCESS; + } + + ldb = ldb_module_get_ctx(ac->module); + schema = dsdb_get_schema(ldb, NULL); + if (!schema) { + ldb_debug_set(ldb, LDB_DEBUG_FATAL, + "samldb_schema_info_update: no dsdb_schema loaded"); + DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); + return LDB_ERR_OPERATIONS_ERROR; + } + + werr = dsdb_module_schema_info_update(ac->module, schema, 0); + if (!W_ERROR_IS_OK(werr)) { + ldb_debug_set(ldb, LDB_DEBUG_FATAL, + "samldb_schema_info_update: " + "dsdb_module_schema_info_update failed with %s", + win_errstr(werr)); + DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); + return LDB_ERR_OPERATIONS_ERROR; + } + + return LDB_SUCCESS; +} + /* * samldb_sid_from_dn (async) */ @@ -1800,6 +1838,12 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) return ret; } + ret = samldb_schema_info_update(ac); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; + } + return samldb_fill_object(ac, "classSchema"); } @@ -1812,6 +1856,12 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) return ret; } + ret = samldb_schema_info_update(ac); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; + } + return samldb_fill_object(ac, "attributeSchema"); }