summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-29 21:27:53 +0200
committerVolker Lendecke <vl@samba.org>2009-05-29 21:29:24 +0200
commitdde62b35d7730d0c09b6479fab7baae809d2551e (patch)
treeee8d128496e1550590142520e3a4131233755d86 /source3/lib
parentf451dd482d1220cb520bbf2cc210c458c25dca26 (diff)
downloadsamba-dde62b35d7730d0c09b6479fab7baae809d2551e.tar.gz
samba-dde62b35d7730d0c09b6479fab7baae809d2551e.tar.bz2
samba-dde62b35d7730d0c09b6479fab7baae809d2551e.zip
Add smbldap_talloc_single_blob()
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/smbldap.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index b6921c329c..b3b5fa7582 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -389,23 +389,42 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
return result;
}
- bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
- struct dom_sid *sid)
+ bool smbldap_talloc_single_blob(TALLOC_CTX *mem_ctx, LDAP *ld,
+ LDAPMessage *msg, const char *attrib,
+ DATA_BLOB *blob)
{
struct berval **values;
- bool ret = False;
values = ldap_get_values_len(ld, msg, attrib);
-
if (!values) {
return false;
}
- if (values[0] != NULL) {
- ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid);
+ if (ldap_count_values_len(values) != 1) {
+ DEBUG(10, ("Expected one value for %s, got %d\n", attrib,
+ ldap_count_values_len(values)));
+ return false;
}
+ *blob = data_blob_talloc(mem_ctx, values[0]->bv_val,
+ values[0]->bv_len);
ldap_value_free_len(values);
+
+ return (blob->data != NULL);
+}
+
+ bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
+ struct dom_sid *sid)
+{
+ DATA_BLOB blob;
+ bool ret;
+
+ if (!smbldap_talloc_single_blob(talloc_tos(), ld, msg, attrib,
+ &blob)) {
+ return false;
+ }
+ ret = sid_parse((char *)blob.data, blob.length, sid);
+ TALLOC_FREE(blob.data);
return ret;
}