The Samba-Bugzilla – Attachment 4042 Details for
Bug 6157
LDAP: MultiValue uid: "attribute uid has 2 values, expected only one" "init_sam_from_ldap: No uid attribute found for this user!"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
0001-Attempt-to-fix-6157.patch (text/plain), 3.16 KB, created by
Volker Lendecke
on 2009-04-01 06:53:47 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Volker Lendecke
Created:
2009-04-01 06:53:47 UTC
Size:
3.16 KB
patch
obsolete
>From 7fd3a97c217b62ff1adaa74bca8d81945dd346a6 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Thu, 12 Mar 2009 17:23:17 +0100 >Subject: [PATCH] Attempt to fix #6157 > >This patch picks the alphabetically smallest one of the multi-value attribute >"uid". This fixes a regression against 3.0 but also becomes deterministic. >--- > source/include/smbldap.h | 3 ++ > source/lib/smbldap.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ > source/passdb/pdb_ldap.c | 2 +- > 3 files changed, 59 insertions(+), 1 deletions(-) > >diff --git a/source/include/smbldap.h b/source/include/smbldap.h >index 79e0a38..fb28f18 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_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); > const char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld, >diff --git a/source/lib/smbldap.c b/source/lib/smbldap.c >index 315b1e3..59a8130 100644 >--- a/source/lib/smbldap.c >+++ b/source/lib/smbldap.c >@@ -332,6 +332,61 @@ 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; >+ 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]) == (size_t)-1) { >+ 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]) >+ == (size_t)-1) { >+ 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/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c >index 0d54fe0..5058ffc 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_single_attribute(priv2ld(ldap_state), >+ if (!(username = smbldap_talloc_smallest_attribute(priv2ld(ldap_state), > entry, > "uid", > ctx))) { >-- >1.5.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 6157
:
3990
| 4042 |
4145
|
5160
|
5174
|
5175