/*
see if a attribute value is in the list of indexed attributes
*/
-static bool ltdb_is_indexed(const struct ldb_message *index_list, const char *attr)
+static bool ltdb_is_indexed(struct ldb_module *module,
+ struct ltdb_private *ltdb,
+ const char *attr)
{
unsigned int i;
struct ldb_message_element *el;
- el = ldb_msg_find_element(index_list, LTDB_IDXATTR);
+ el = ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR);
if (el == NULL) {
return false;
}
equality search only)
*/
static int ltdb_index_dn_simple(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
struct ldb_context *ldb;
/* if the attribute isn't in the list of indexed attributes then
this node needs a full search */
- if (!ltdb_is_indexed(index_list, tree->u.equality.attr)) {
+ if (!ltdb_is_indexed(module, ltdb, tree->u.equality.attr)) {
return LDB_ERR_OPERATIONS_ERROR;
}
return a list of dn's that might match a leaf indexed search
*/
static int ltdb_index_dn_leaf(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module),
- struct ltdb_private);
if (ltdb->disallow_dn_filter &&
(ldb_attr_cmp(tree->u.equality.attr, "dn") == 0)) {
/* in AD mode we do not support "(dn=...)" search filters */
list->count = 1;
return LDB_SUCCESS;
}
- return ltdb_index_dn_simple(module, tree, index_list, list);
+ return ltdb_index_dn_simple(module, ltdb, tree, list);
}
}
static int ltdb_index_dn(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list);
process an OR list (a union)
*/
static int ltdb_index_dn_or(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
struct ldb_context *ldb;
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ltdb_index_dn(module, tree->u.list.elements[i], index_list, list2);
+ ret = ltdb_index_dn(module, ltdb,
+ tree->u.list.elements[i], list2);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* X || 0 == X */
NOT an index results
*/
static int ltdb_index_dn_not(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
/* the only way to do an indexed not would be if we could
process an AND expression (intersection)
*/
static int ltdb_index_dn_and(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
struct ldb_context *ldb;
continue;
}
- ret = ltdb_index_dn(module, subtree, index_list, list);
+ ret = ltdb_index_dn(module, ltdb, subtree, list);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* 0 && X == 0 */
return LDB_ERR_NO_SUCH_OBJECT;
return ldb_module_oom(module);
}
- ret = ltdb_index_dn(module, subtree, index_list, list2);
+ ret = ltdb_index_dn(module, ltdb, subtree, list2);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* X && 0 == 0 */
an error. return LDB_ERR_NO_SUCH_OBJECT for no matches, or LDB_SUCCESS for matches
*/
static int ltdb_index_dn(struct ldb_module *module,
+ struct ltdb_private *ltdb,
const struct ldb_parse_tree *tree,
- const struct ldb_message *index_list,
struct dn_list *list)
{
int ret = LDB_ERR_OPERATIONS_ERROR;
switch (tree->operation) {
case LDB_OP_AND:
- ret = ltdb_index_dn_and(module, tree, index_list, list);
+ ret = ltdb_index_dn_and(module, ltdb, tree, list);
break;
case LDB_OP_OR:
- ret = ltdb_index_dn_or(module, tree, index_list, list);
+ ret = ltdb_index_dn_or(module, ltdb, tree, list);
break;
case LDB_OP_NOT:
- ret = ltdb_index_dn_not(module, tree, index_list, list);
+ ret = ltdb_index_dn_not(module, ltdb, tree, list);
break;
case LDB_OP_EQUALITY:
- ret = ltdb_index_dn_leaf(module, tree, index_list, list);
+ ret = ltdb_index_dn_leaf(module, ltdb, tree, list);
break;
case LDB_OP_SUBSTRING:
talloc_free(dn_list);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ltdb_index_dn(ac->module, ac->tree, ltdb->cache->indexlist, dn_list);
+ ret = ltdb_index_dn(ac->module, ltdb, ac->tree, dn_list);
if (ret != LDB_SUCCESS) {
talloc_free(dn_list);
return ret;
for (i = 0; i < num_el; i++) {
int ret;
- if (!ltdb_is_indexed(ltdb->cache->indexlist, elements[i].name)) {
+ if (!ltdb_is_indexed(module, ltdb, elements[i].name)) {
continue;
}
ret = ltdb_index_add_el(module, dn, &elements[i], is_new);
if (ldb_dn_is_special(dn)) {
return LDB_SUCCESS;
}
- if (!ltdb_is_indexed(ltdb->cache->indexlist, el->name)) {
+ if (!ltdb_is_indexed(module, ltdb, el->name)) {
return LDB_SUCCESS;
}
return ltdb_index_add_el(module, ldb_dn_get_linearized(dn), el, true);
return LDB_SUCCESS;
}
- if (!ltdb_is_indexed(ltdb->cache->indexlist, el->name)) {
+ if (!ltdb_is_indexed(module, ltdb, el->name)) {
return LDB_SUCCESS;
}
for (i = 0; i < el->num_values; i++) {