diff options
author | Andrew Bartlett <abartlet@samba.org> | 2017-08-10 17:12:30 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-09-22 21:20:22 +0200 |
commit | 6008382191f5115539906f264050b80b61b0693b (patch) | |
tree | fede7e3006037cb7f898d3a67481c99d3bf367d5 /lib/ldb | |
parent | fa44c5262b5485273e39b52dc821a74ce6878515 (diff) | |
download | samba-6008382191f5115539906f264050b80b61b0693b.tar.gz |
ldb_tdb: Optionally use GUID index in ltdb_search_dn1()
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'lib/ldb')
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_search.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c index 350f01b8093..249ecfeb810 100644 --- a/lib/ldb/ldb_tdb/ldb_search.c +++ b/lib/ldb/ldb_tdb/ldb_search.c @@ -271,11 +271,28 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes return ldb_module_oom(module); } - /* form the key */ - tdb_key = ltdb_key_dn(module, tdb_key_ctx, dn); - if (!tdb_key.dptr) { - TALLOC_FREE(tdb_key_ctx); - return LDB_ERR_OPERATIONS_ERROR; + if (ltdb->cache->GUID_index_attribute == NULL) { + /* form the key */ + tdb_key = ltdb_key_dn(module, tdb_key_ctx, dn); + if (!tdb_key.dptr) { + TALLOC_FREE(tdb_key_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + } else if (ldb_dn_is_special(dn)) { + /* form the key */ + tdb_key = ltdb_key_dn(module, tdb_key_ctx, dn); + if (!tdb_key.dptr) { + TALLOC_FREE(tdb_key_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + } else { + /* Look in the index to find the key for this DN */ + ret = ltdb_key_dn_from_idx(module, ltdb, tdb_key_ctx, + dn, &tdb_key); + if (ret != LDB_SUCCESS) { + TALLOC_FREE(tdb_key_ctx); + return ret; + } } ret = ltdb_search_key(module, ltdb, tdb_key, msg, unpack_flags); |