summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/operational.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c
index 1d0269854f..9fc0d1aeae 100644
--- a/source4/dsdb/samdb/ldb_modules/operational.c
+++ b/source4/dsdb/samdb/ldb_modules/operational.c
@@ -265,7 +265,21 @@ static int construct_subschema_subentry(struct ldb_module *module,
{
struct operational_data *data = talloc_get_type(ldb_module_get_private(module), struct operational_data);
char *subSchemaSubEntry;
- if (data && data->aggregate_dn) {
+
+ /* We may be being called before the init function has finished */
+ if (!data) {
+ return LDB_SUCCESS;
+ }
+
+ /* Try and set this value up, if possible. Don't worry if it
+ * fails, we may not have the DB set up yet, and it's not
+ * really vital anyway */
+ if (!data->aggregate_dn) {
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ data->aggregate_dn = samdb_aggregate_schema_dn(ldb, data);
+ }
+
+ if (data->aggregate_dn) {
subSchemaSubEntry = ldb_dn_alloc_linearized(msg, data->aggregate_dn);
return ldb_msg_add_steal_string(msg, "subSchemaSubEntry", subSchemaSubEntry);
}
@@ -563,25 +577,18 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
static int operational_init(struct ldb_module *ctx)
{
struct operational_data *data;
- struct ldb_context *ldb = ldb_module_get_ctx(ctx);
int ret = ldb_next_init(ctx);
if (ret != LDB_SUCCESS) {
return ret;
}
- data = talloc(ctx, struct operational_data);
+ data = talloc_zero(ctx, struct operational_data);
if (!data) {
ldb_module_oom(ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
- data->aggregate_dn = samdb_aggregate_schema_dn(ldb, data);
- if (!data->aggregate_dn) {
- ldb_set_errstring(ldb, "Could not build aggregate schema DN");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
ldb_module_set_private(ctx, data);
return LDB_SUCCESS;