From 1f264d14d3a79285d2df89cc85492ee78fb93175 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Jan 2010 13:30:19 +0100 Subject: [PATCH 1/2] s3:smbldap: add smbldap_talloc_first_attribute() metze Signed-off-by: Stefan Metzmacher --- source/include/smbldap.h | 3 +++ source/lib/smbldap.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/source/include/smbldap.h b/source/include/smbldap.h index e312bb2..0fe1d6c 100644 --- a/source/include/smbldap.h +++ b/source/include/smbldap.h @@ -212,6 +212,9 @@ const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver ); char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry, const char *attribute, TALLOC_CTX *mem_ctx); +char * smbldap_talloc_first_attribute(LDAP *ldap_struct, LDAPMessage *entry, + const char *attribute, + TALLOC_CTX *mem_ctx); char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry, const char *attribute, TALLOC_CTX *mem_ctx); diff --git a/source/lib/smbldap.c b/source/lib/smbldap.c index 704a516..6678ad9 100644 --- a/source/lib/smbldap.c +++ b/source/lib/smbldap.c @@ -333,6 +333,40 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = { return result; } + char * smbldap_talloc_first_attribute(LDAP *ldap_struct, LDAPMessage *entry, + const char *attribute, + TALLOC_CTX *mem_ctx) +{ + char **values; + char *result; + size_t converted_size; + + 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; + } + + ldap_value_free(values); + +#ifdef DEBUG_PASSWORDS + DEBUG (100, ("smbldap_get_first_attribute: [%s] = [%s]\n", + attribute, result)); +#endif + return result; +} + char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry, const char *attribute, TALLOC_CTX *mem_ctx) -- 1.6.3.3 From 731ac0ee0e6a8d2b87c9561a8d20c0a29ccc4b17 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Jan 2010 13:30:42 +0100 Subject: [PATCH 2/2] s3:pdb_ldap: restore Samba 3.0.x behavior and use the first "uid" value. See bug #6157 for more details. metze Signed-off-by: Stefan Metzmacher --- source/passdb/pdb_ldap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c index 73f3e87..c4f0e91 100644 --- a/source/passdb/pdb_ldap.c +++ b/source/passdb/pdb_ldap.c @@ -559,7 +559,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state, goto fn_exit; } - if (!(username = smbldap_talloc_smallest_attribute(priv2ld(ldap_state), + if (!(username = smbldap_talloc_first_attribute(priv2ld(ldap_state), entry, "uid", ctx))) { -- 1.6.3.3