s4:ldb Add a function to match a message against an objectClass
authorAndrew Bartlett <abartlet@samba.org>
Mon, 7 Dec 2009 04:27:43 +0000 (15:27 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 7 Dec 2009 04:27:43 +0000 (15:27 +1100)
(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

source4/lib/ldb/common/ldb_match.c
source4/lib/ldb/include/ldb_module.h

index e6ee0de0274e9b5e6f85b39687552bd47d6204d5..f639effc96b17f621fca53360ce84af92e6a015d 100644 (file)
@@ -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;
+}
+
+
+                             
index 7c18683201efaee75faa1c823bee26a81461f668..0b0f863fec0552adaad36ef5532b91a21d5cb29f 100644 (file)
@@ -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,