Add tldap_entry_has_attrvalue
authorVolker Lendecke <vl@samba.org>
Fri, 19 Jun 2009 12:00:31 +0000 (14:00 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 20 Jun 2009 16:54:06 +0000 (18:54 +0200)
source3/include/tldap_util.h
source3/lib/tldap_util.c

index 8869d1e9de3b1dc8148a221e898867e6d242168a..00916f51f3640da39a1e014a7c5ea72bfe899419 100644 (file)
@@ -61,4 +61,8 @@ int tldap_fetch_rootdse_recv(struct tevent_req *req);
 int tldap_fetch_rootdse(struct tldap_context *ld);
 struct tldap_message *tldap_rootdse(struct tldap_context *ld);
 
+bool tldap_entry_has_attrvalue(struct tldap_message *msg,
+                              const char *attribute,
+                              const DATA_BLOB blob);
+
 #endif
index 3698264bd631137abcaba99a1b8ca31979397ade..e217cccd0b6d755b5c29879f3a5951819ff69b61 100644 (file)
@@ -509,3 +509,21 @@ struct tldap_message *tldap_rootdse(struct tldap_context *ld)
        return talloc_get_type(tldap_context_getattr(ld, "tldap:rootdse"),
                               struct tldap_message);
 }
+
+bool tldap_entry_has_attrvalue(struct tldap_message *msg,
+                              const char *attribute,
+                              const DATA_BLOB blob)
+{
+       int i, num_values;
+       DATA_BLOB *values;
+
+       if (!tldap_entry_values(msg, attribute, &num_values, &values)) {
+               return false;
+       }
+       for (i=0; i<num_values; i++) {
+               if (data_blob_cmp(&values[i], &blob) == 0) {
+                       return true;
+               }
+       }
+       return false;
+}