[SCM] Samba Shared Repository - branch v3-4-test updated -
release-4-0-0alpha7-953-gb1d864d
Volker Lendecke
vlendec at samba.org
Tue May 12 13:22:44 GMT 2009
The branch, v3-4-test has been updated
via b1d864d1006aab53a1692175adf2c64897eeffd9 (commit)
from 502d9ec5d1f37cd5d992324025b88756b6a475ec (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test
- Log -----------------------------------------------------------------
commit b1d864d1006aab53a1692175adf2c64897eeffd9
Author: Volker Lendecke <vl at samba.org>
Date: Thu Mar 12 17:23:17 2009 +0100
Fix bug 6157
This patch picks the alphabetically smallest one of the multi-value attribute
"uid". This fixes a regression against 3.0 and also becomes deterministic.
-----------------------------------------------------------------------
Summary of changes:
source3/include/smbldap.h | 3 ++
source3/lib/smbldap.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
source3/passdb/pdb_ldap.c | 2 +-
3 files changed, 60 insertions(+), 1 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/smbldap.h b/source3/include/smbldap.h
index 353e01a..3ac770a 100644
--- a/source3/include/smbldap.h
+++ b/source3/include/smbldap.h
@@ -211,6 +211,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_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
+ const char *attribute,
+ TALLOC_CTX *mem_ctx);
void talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result);
void talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod);
char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld,
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 4f54f9a..f86b711 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<num_values; i++) {
+ char *tmp;
+
+ if (!pull_utf8_talloc(mem_ctx, &tmp, values[i],
+ &converted_size)) {
+ DEBUG(10, ("pull_utf8_talloc failed\n"));
+ TALLOC_FREE(result);
+ ldap_value_free(values);
+ return NULL;
+ }
+
+ if (StrCaseCmp(tmp, result) < 0) {
+ TALLOC_FREE(result);
+ result = tmp;
+ } else {
+ TALLOC_FREE(tmp);
+ }
+ }
+
+ ldap_value_free(values);
+
+#ifdef DEBUG_PASSWORDS
+ DEBUG (100, ("smbldap_get_single_attribute: [%s] = [%s]\n",
+ attribute, result));
+#endif
+ return result;
+}
+
static int ldapmsg_destructor(LDAPMessage **result) {
ldap_msgfree(*result);
return 0;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 8775b79..1e170f4 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/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_single_attribute(priv2ld(ldap_state),
+ if (!(username = smbldap_talloc_smallest_attribute(priv2ld(ldap_state),
entry,
"uid",
ctx))) {
--
Samba Shared Repository
More information about the samba-cvs
mailing list