diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-02-27 00:39:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:52:06 -0500 |
commit | 57d5f19b3f032dfcecde9883651c6df8b18a8b58 (patch) | |
tree | ff516943fed75891c2ac4333352ecb6dcb04139e /source4/lib/ldb/ldb_tdb/ldb_tdb.c | |
parent | e964109e6a9c18c668ef6c1ac534693bb981e18f (diff) | |
download | samba-57d5f19b3f032dfcecde9883651c6df8b18a8b58.tar.gz samba-57d5f19b3f032dfcecde9883651c6df8b18a8b58.tar.bz2 samba-57d5f19b3f032dfcecde9883651c6df8b18a8b58.zip |
r13700: added highestCommittedUSN, uSNChanged and uSNCreated support, using
the @BASEINFO sequenceNumber
(simo, I changed the function pointer to a structure element as you
preferred)
(This used to be commit 68c9ac38c7eed221b44499ee3d74597063dfe7a1)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 8d8c01278d..b58b03f221 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -772,6 +772,31 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req) } } +/* + return sequenceNumber from @BASEINFO +*/ +static uint64_t ltdb_sequence_number(struct ldb_context *ldb) +{ + TALLOC_CTX *tmp_ctx = talloc_new(ldb); + const char *attrs[] = { "sequenceNumber", NULL }; + struct ldb_result *res = NULL; + struct ldb_dn *dn = ldb_dn_explode(tmp_ctx, "@BASEINFO"); + int ret; + uint64_t seq_num; + + ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res); + talloc_steal(tmp_ctx, res); + if (ret != LDB_SUCCESS || res->count != 1) { + talloc_free(tmp_ctx); + /* zero is as good as anything when we don't know */ + return 0; + } + + seq_num = ldb_msg_find_uint64(res->msgs[0], "sequenceNumber", 0); + talloc_free(tmp_ctx); + return seq_num; +} + static int ltdb_init_2(struct ldb_module *module) { return LDB_SUCCESS; @@ -847,6 +872,7 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, ldb->modules->prev = ldb->modules->next = NULL; ldb->modules->private_data = ltdb; ldb->modules->ops = <db_ops; + ldb->sequence_number = ltdb_sequence_number; return 0; } |