X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=blobdiff_plain;f=source3%2Flib%2Fsmbldap.c;h=4360d3ab578008860d61d4bba291bc4047af95ea;hp=63629265f1994ee5f717de8bc2874c5fb769ac9d;hb=c9efd454c5ffe0126bb21fdaadd421d71c38e2f7;hpb=94665adb484c25534b756012e9b55f01737b7713 diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 63629265f19..4360d3ab578 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -333,6 +333,62 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = { return result; } + char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry, + const char *attribute, + TALLOC_CTX *mem_ctx) +{ + char **values; + char *result; + size_t converted_size; + int i, num_values; + + if (attribute == NULL) { + return NULL; + } + + values = ldap_get_values(ldap_struct, entry, attribute); + + if (values == NULL) { + DEBUG(10, ("attribute %s does not exist\n", attribute)); + return NULL; + } + + if (!pull_utf8_talloc(mem_ctx, &result, values[0], &converted_size)) { + DEBUG(10, ("pull_utf8_talloc failed\n")); + ldap_value_free(values); + return NULL; + } + + num_values = ldap_count_values(values); + + for (i=1; i