static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_dn, uint64_t current_usn,
struct dsdb_schema **schema);
-struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema)
+static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema)
{
uint64_t current_usn;
int ret;
schema->reload_seq_number = tseqr->seq_num;
talloc_free(res);
- ret = dsdb_module_load_partition_usn(module, schema->base_dn, ¤t_usn, NULL);
+ ret = dsdb_module_load_partition_usn(module, schema->base_dn, ¤t_usn, NULL, NULL);
if (ret != LDB_SUCCESS || current_usn == schema->loaded_usn) {
return schema;
}
char *error_string;
int ret;
struct ldb_result *schema_res;
- struct ldb_result *a_res;
- struct ldb_result *c_res;
+ struct ldb_result *res;
static const char *schema_attrs[] = {
"prefixMap",
"schemaInfo",
*/
ret = dsdb_module_search_dn(module, tmp_ctx, &schema_res,
schema_dn, schema_attrs,
- DSDB_FLAG_NEXT_MODULE);
+ DSDB_FLAG_NEXT_MODULE, NULL);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_reset_err_string(ldb);
ldb_debug(ldb, LDB_DEBUG_WARNING,
/*
* load the attribute definitions
*/
- ret = dsdb_module_search(module, tmp_ctx, &a_res,
- schema_dn, LDB_SCOPE_ONELEVEL, NULL,
- DSDB_FLAG_NEXT_MODULE,
- "(objectClass=attributeSchema)");
- if (ret != LDB_SUCCESS) {
- ldb_asprintf_errstring(ldb,
- "dsdb_schema: failed to search attributeSchema objects: %s",
- ldb_errstring(ldb));
- goto failed;
- }
-
- /*
- * load the objectClass definitions
- */
- ret = dsdb_module_search(module, tmp_ctx, &c_res,
+ ret = dsdb_module_search(module, tmp_ctx, &res,
schema_dn, LDB_SCOPE_ONELEVEL, NULL,
DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
- "(objectClass=classSchema)");
+ NULL,
+ "(|(objectClass=attributeSchema)(objectClass=classSchema))");
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
- "dsdb_schema: failed to search classSchema objects: %s",
+ "dsdb_schema: failed to search attributeSchema and classSchema objects: %s",
ldb_errstring(ldb));
goto failed;
}
ret = dsdb_schema_from_ldb_results(tmp_ctx, ldb,
- schema_res, a_res, c_res, schema, &error_string);
+ schema_res, res, schema, &error_string);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"dsdb_schema load failed: %s",
/* "dsdb_set_schema()" steals schema into the ldb_context */
ret = dsdb_set_schema(ldb, (*schema));
- if (*schema != NULL) {
- (*schema)->refresh_in_progress = false;
- }
+ (*schema)->refresh_in_progress = false;
if (ret != LDB_SUCCESS) {
ldb_debug_set(ldb, LDB_DEBUG_FATAL,
return LDB_SUCCESS;
}
- ret = dsdb_module_load_partition_usn(module, schema_dn, ¤t_usn, NULL);
+ ret = dsdb_module_load_partition_usn(module, schema_dn, ¤t_usn, NULL, NULL);
if (ret != LDB_SUCCESS) {
/* Ignore the error and just reload the DB more often */
current_usn = 0;
return ldb_next_start_trans(module);
}
-static int schema_load_del_transaction(struct ldb_module *module)
+static int schema_load_end_transaction(struct ldb_module *module)
{
struct schema_load_private_data *private_data =
talloc_get_type(ldb_module_get_private(module), struct schema_load_private_data);
private_data->in_transaction = false;
- return ldb_next_del_trans(module);
+ return ldb_next_end_trans(module);
}
-static int schema_load_prepare_commit(struct ldb_module *module)
+static int schema_load_del_transaction(struct ldb_module *module)
{
- int ret;
struct schema_load_private_data *private_data =
talloc_get_type(ldb_module_get_private(module), struct schema_load_private_data);
- ret = ldb_next_prepare_commit(module);
private_data->in_transaction = false;
- return ret;
+
+ return ldb_next_del_trans(module);
}
static int schema_load_extended(struct ldb_module *module, struct ldb_request *req)
}
-_PUBLIC_ const struct ldb_module_ops ldb_schema_load_module_ops = {
+static const struct ldb_module_ops ldb_schema_load_module_ops = {
.name = "schema_load",
.init_context = schema_load_init,
.extended = schema_load_extended,
.start_transaction = schema_load_start_transaction,
- .prepare_commit = schema_load_prepare_commit,
+ .end_transaction = schema_load_end_transaction,
.del_transaction = schema_load_del_transaction,
};
+
+int ldb_schema_load_module_init(const char *version)
+{
+ LDB_MODULE_CHECK_VERSION(version);
+ return ldb_register_module(&ldb_schema_load_module_ops);
+}