summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb.c10
-rw-r--r--source4/lib/ldb/include/ldb_private.h5
-rw-r--r--source4/lib/ldb/modules/operational.c23
3 files changed, 22 insertions, 16 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index c059646629..8e814778d1 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -103,7 +103,7 @@ static ldb_connect_fn ldb_find_backend(const char *url)
This allows modules to get at only the backend module, for example where a module
may wish to direct certain requests at a particular backend.
*/
-int ldb_connect_backend(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[],
+int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
struct ldb_module **backend_module)
{
int ret;
@@ -132,7 +132,7 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, unsigned int f
return LDB_ERR_OTHER;
}
- ret = fn(ldb, url, flags, options, backend_module);
+ ret = fn(ldb, url, ldb->flags, options, backend_module);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to connect to '%s'\n", url);
@@ -156,7 +156,9 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
{
int ret;
- ret = ldb_connect_backend(ldb, url, flags, options, &ldb->modules);
+ ldb->flags = flags;
+
+ ret = ldb_connect_backend(ldb, url, options, &ldb->modules);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -701,7 +703,7 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct
/*
- rename a record in the database
+ return the global sequence number
*/
int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num)
{
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index a10c343352..2f2df1a970 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -117,8 +117,7 @@ struct ldb_context {
int default_timeout;
- /* a backend supplied highestCommittedUSN function */
- uint64_t (*sequence_number)(struct ldb_context *);
+ unsigned int flags;
};
#ifndef ARRAY_SIZE
@@ -132,7 +131,7 @@ struct ldb_context {
/* The following definitions come from lib/ldb/common/ldb.c */
-int ldb_connect_backend(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[],
+int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
struct ldb_module **backend_module);
/* The following definitions come from lib/ldb/common/ldb_modules.c */
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index b404e94580..a15a553286 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -349,6 +349,7 @@ static int operational_add(struct ldb_module *module, struct ldb_request *req)
struct ldb_request *down_req;
struct ldb_message *msg;
time_t t = time(NULL);
+ uint64_t seq_num;
int ret;
if (ldb_dn_is_special(req->op.add.message->dn)) {
@@ -373,9 +374,9 @@ static int operational_add(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- /* see if the backend can give us the USN */
- if (module->ldb->sequence_number != NULL) {
- uint64_t seq_num = module->ldb->sequence_number(module->ldb);
+ /* Get a sequence number from the backend */
+ ret = ldb_sequence_number(module->ldb, &seq_num);
+ if (ret == LDB_SUCCESS) {
if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 ||
add_uint64_element(msg, "uSNChanged", seq_num) != 0) {
talloc_free(down_req);
@@ -405,6 +406,7 @@ static int operational_modify(struct ldb_module *module, struct ldb_request *req
struct ldb_request *down_req;
struct ldb_message *msg;
time_t t = time(NULL);
+ uint64_t seq_num;
int ret;
if (ldb_dn_is_special(req->op.mod.message->dn)) {
@@ -428,12 +430,15 @@ static int operational_modify(struct ldb_module *module, struct ldb_request *req
return LDB_ERR_OPERATIONS_ERROR;
}
- /* update the records USN if possible */
- if (module->ldb->sequence_number != NULL &&
- add_uint64_element(msg, "uSNChanged",
- module->ldb->sequence_number(module->ldb)) != 0) {
- talloc_free(down_req);
- return -1;
+ /* Get a sequence number from the backend */
+ ret = ldb_sequence_number(module->ldb, &seq_num);
+ if (ret == LDB_SUCCESS) {
+ /* update the records USN if possible */
+ if (add_uint64_element(msg, "uSNChanged",
+ seq_num) != 0) {
+ talloc_free(down_req);
+ return -1;
+ }
}
ldb_set_timeout_from_prev_req(module->ldb, req, down_req);