summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/tldap_util.h4
-rw-r--r--source3/lib/tldap_util.c18
2 files changed, 22 insertions, 0 deletions
diff --git a/source3/include/tldap_util.h b/source3/include/tldap_util.h
index 8869d1e9de..00916f51f3 100644
--- a/source3/include/tldap_util.h
+++ b/source3/include/tldap_util.h
@@ -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
diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c
index 3698264bd6..e217cccd0b 100644
--- a/source3/lib/tldap_util.c
+++ b/source3/lib/tldap_util.c
@@ -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;
+}