diff options
author | Nadezhda Ivanova <nivanova@samba.org> | 2010-09-22 12:50:51 -0700 |
---|---|---|
committer | Nadezhda Ivanova <nivanova@samba.org> | 2010-09-26 15:36:09 -0700 |
commit | 4d3f528411301d0bc48110921a1ecb4b4f752b1e (patch) | |
tree | b0ea91c0a246a852cabc9366377c8c9a6b0f9714 /source4 | |
parent | b77edca7f8728fbba8d4a3e6fe9f226793dad9cb (diff) | |
download | samba-4d3f528411301d0bc48110921a1ecb4b4f752b1e.tar.gz samba-4d3f528411301d0bc48110921a1ecb4b4f752b1e.tar.bz2 samba-4d3f528411301d0bc48110921a1ecb4b4f752b1e.zip |
s4-dsdb: A helper to determine if an attribute is part of the search filter
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/common/util.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index a5d7caeefe..7bf26184fc 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -4075,3 +4075,49 @@ const char *samdb_dn_to_dnshostname(struct ldb_context *ldb, return samdb_result_string(res->msgs[0], "dNSHostName", NULL); } + +/* + returns true if an attribute is in the filter, + false otherwise, provided that attribute value is provided with the expression +*/ +bool dsdb_attr_in_parse_tree(struct ldb_parse_tree *tree, + const char *attr) +{ + unsigned int i; + switch (tree->operation) { + case LDB_OP_AND: + case LDB_OP_OR: + for (i=0;i<tree->u.list.num_elements;i++) { + if (dsdb_attr_in_parse_tree(tree->u.list.elements[i], + attr)) + return true; + } + return false; + case LDB_OP_NOT: + return dsdb_attr_in_parse_tree(tree->u.isnot.child, attr); + case LDB_OP_EQUALITY: + case LDB_OP_GREATER: + case LDB_OP_LESS: + case LDB_OP_APPROX: + if (ldb_attr_cmp(tree->u.equality.attr, attr) == 0) { + return true; + } + return false; + case LDB_OP_SUBSTRING: + if (ldb_attr_cmp(tree->u.substring.attr, attr) == 0) { + return true; + } + return false; + case LDB_OP_PRESENT: + /* (attrname=*) is not filtered out */ + return false; + case LDB_OP_EXTENDED: + if (tree->u.extended.attr && + ldb_attr_cmp(tree->u.extended.attr, attr) == 0) { + return true; + } + return false; + } + return false; +} + |