diff options
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 16 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_search.c | 35 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 1 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.h | 3 |
4 files changed, 15 insertions, 40 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index f78d840206..c2a4fb1ea8 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -676,7 +676,8 @@ int ltdb_search_indexed(struct ldb_module *module, struct dn_list *dn_list; int ret; - if (ltdb->cache->indexlist->num_elements == 0) { + if (ltdb->cache->indexlist->num_elements == 0 && + scope != LDB_SCOPE_BASE) { /* no index list? must do full search */ return -1; } @@ -686,7 +687,18 @@ int ltdb_search_indexed(struct ldb_module *module, return -1; } - ret = ltdb_index_dn(module, tree, ltdb->cache->indexlist, dn_list); + if (scope == LDB_SCOPE_BASE) { + /* with BASE searches only one DN can match */ + char *dn = ldb_dn_linearize(dn_list, base); + if (dn == NULL) { + return -1; + } + dn_list->count = 1; + dn_list->dn = &dn; + ret = 1; + } else { + ret = ltdb_index_dn(module, tree, ltdb->cache->indexlist, dn_list); + } if (ret == 1) { /* we've got a candidate list - now filter by the full tree diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 574d9485f8..eb89753007 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -95,7 +95,7 @@ static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *r for (i=0;i<msg->num_elements;i++) { const struct ldb_attrib_handler *h; h = ldb_attrib_handler(ldb, msg->elements[i].name); - if (ldb_dn_is_special(msg->dn) && (h->flags & LDB_ATTR_FLAG_HIDDEN)) { + if (h->flags & LDB_ATTR_FLAG_HIDDEN) { continue; } if (msg_add_element(ldb, ret, &msg->elements[i]) != 0) { @@ -501,17 +501,6 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base, if ((base == NULL || base->comp_num == 0) && (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) return -1; - /* check if we are looking for a simple dn */ - if (scope == LDB_SCOPE_BASE && tree == NULL) { - return ltdb_search_dn(module, base, attrs, res); - } - - if (tree == NULL) { - char *err_string = talloc_strdup(module, "expression parse failed"); - if (err_string) ldb_set_errstring(module, err_string); - return -1; - } - /* it is important that we handle dn queries this way, and not via a full db search, otherwise ldb is horribly slow */ if (tree->operation == LDB_OP_EQUALITY && @@ -549,25 +538,3 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base, } -/* - search the database with a LDAP-like expression. - choses a search method -*/ -int ltdb_search(struct ldb_module *module, const struct ldb_dn *base, - enum ldb_scope scope, const char *expression, - const char * const attrs[], struct ldb_message ***res) -{ - struct ltdb_private *ltdb = module->private_data; - struct ldb_parse_tree *tree; - int ret; - - if ((base == NULL || base->comp_num == 0) && - (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) return -1; - - tree = ldb_parse_tree(ltdb, expression); - - ret = ltdb_search_bytree(module, base, scope, tree, attrs, res); - talloc_free(tree); - return ret; -} - diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 701ed602ce..22360ffb1c 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -702,7 +702,6 @@ static int ltdb_del_trans(struct ldb_module *module) static const struct ldb_module_ops ltdb_ops = { .name = "tdb", - .search = ltdb_search, .search_bytree = ltdb_search_bytree, .add_record = ltdb_add, .modify_record = ltdb_modify, diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index c16db67e1f..2819d865d3 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -83,9 +83,6 @@ int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg, const char * const attrs[], int *count, struct ldb_message ***res); -int ltdb_search(struct ldb_module *module, const struct ldb_dn *base, - enum ldb_scope scope, const char *expression, - const char * const attrs[], struct ldb_message ***res); int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const attrs[], struct ldb_message ***res); |