mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
ldap: Fixed Unicode user and password in Win32 bind calls
This commit is contained in:
parent
0f26148423
commit
6416dc998b
29
lib/ldap.c
29
lib/ldap.c
@ -188,8 +188,12 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
#if defined(CURL_LDAP_WIN) && \
|
#if defined(CURL_LDAP_WIN) && \
|
||||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||||
TCHAR *host = NULL;
|
TCHAR *host = NULL;
|
||||||
|
TCHAR *user = NULL;
|
||||||
|
TCHAR *passwd = NULL;
|
||||||
#else
|
#else
|
||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
|
char *user = NULL;
|
||||||
|
char *passwd = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*done = TRUE; /* unconditionally */
|
*done = TRUE; /* unconditionally */
|
||||||
@ -222,8 +226,23 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(conn->bits.user_passwd) {
|
||||||
|
user = Curl_convert_UTF8_to_tchar(conn->user);
|
||||||
|
passwd = Curl_convert_UTF8_to_tchar(conn->passwd);
|
||||||
|
if(!user || !passwd) {
|
||||||
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
host = conn->host.name;
|
host = conn->host.name;
|
||||||
|
|
||||||
|
if(conn->bits.user_passwd) {
|
||||||
|
user = conn->user;
|
||||||
|
passwd = conn->passwd;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LDAP_OPT_NETWORK_TIMEOUT
|
#ifdef LDAP_OPT_NETWORK_TIMEOUT
|
||||||
@ -370,15 +389,11 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = ldap_simple_bind_s(server,
|
rc = ldap_simple_bind_s(server, user, passwd);
|
||||||
conn->bits.user_passwd ? conn->user : NULL,
|
|
||||||
conn->bits.user_passwd ? conn->passwd : NULL);
|
|
||||||
if(!ldap_ssl && rc != 0) {
|
if(!ldap_ssl && rc != 0) {
|
||||||
ldap_proto = LDAP_VERSION2;
|
ldap_proto = LDAP_VERSION2;
|
||||||
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
||||||
rc = ldap_simple_bind_s(server,
|
rc = ldap_simple_bind_s(server, user, passwd);
|
||||||
conn->bits.user_passwd ? conn->user : NULL,
|
|
||||||
conn->bits.user_passwd ? conn->passwd : NULL);
|
|
||||||
}
|
}
|
||||||
if(rc != 0) {
|
if(rc != 0) {
|
||||||
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
|
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
|
||||||
@ -572,6 +587,8 @@ quit:
|
|||||||
|
|
||||||
#if defined(CURL_LDAP_WIN) && \
|
#if defined(CURL_LDAP_WIN) && \
|
||||||
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
(defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI))
|
||||||
|
Curl_unicodefree(passwd);
|
||||||
|
Curl_unicodefree(user);
|
||||||
Curl_unicodefree(host);
|
Curl_unicodefree(host);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user