summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-12-07 15:27:43 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-12-07 15:27:43 +1100
commit54ea4b17f06a6f2fb343111be22f28191d21fdf1 (patch)
treea1ff01d3627e32e363395501fba0410354513cb3 /source4/lib/ldb
parentb2db28b634bceccb4c87e3f764649a5ed1f3217a (diff)
downloadsamba-54ea4b17f06a6f2fb343111be22f28191d21fdf1.tar.gz
samba-54ea4b17f06a6f2fb343111be22f28191d21fdf1.tar.bz2
samba-54ea4b17f06a6f2fb343111be22f28191d21fdf1.zip
s4:ldb Add a function to match a message against an objectClass
(as objectClass will always be a case insensitive ascii string, we can make a much simpler match function here than for the general case). Andrew Bartlett
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_match.c19
-rw-r--r--source4/lib/ldb/include/ldb_module.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c
index e6ee0de027..f639effc96 100644
--- a/source4/lib/ldb/common/ldb_match.c
+++ b/source4/lib/ldb/common/ldb_match.c
@@ -426,3 +426,22 @@ int ldb_match_msg(struct ldb_context *ldb,
return ldb_match_message(ldb, msg, tree, scope);
}
+
+int ldb_match_msg_objectclass(const struct ldb_message *msg,
+ const char *objectclass)
+{
+ int i;
+ struct ldb_message_element *el = ldb_msg_find_element(msg, "objectClass");
+ if (!el) {
+ return 0;
+ }
+ for (i=0; i < el->num_values; i++) {
+ if (ldb_attr_cmp((const char *)el->values[i].data, objectclass) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+
diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h
index 7c18683201..0b0f863fec 100644
--- a/source4/lib/ldb/include/ldb_module.h
+++ b/source4/lib/ldb/include/ldb_module.h
@@ -126,6 +126,9 @@ int ldb_match_msg(struct ldb_context *ldb,
struct ldb_dn *base,
enum ldb_scope scope);
+int ldb_match_msg_objectclass(const struct ldb_message *msg,
+ const char *objectclass);
+
/* The following definitions come from lib/ldb/common/ldb_modules.c */
struct ldb_module *ldb_module_new(TALLOC_CTX *memctx,