--------------------- PatchSet 6106 Date: 2004/01/03 11:12:45 Author: serassio Branch: nt-2_5 Tag: (none) Log: Fixed Windows LDAP support problems Members: helpers/basic_auth/LDAP/squid_ldap_auth.c:1.2.8.10->1.2.8.11 helpers/external_acl/ldap_group/squid_ldap_group.c:1.1.6.9->1.1.6.10 Index: squid/helpers/basic_auth/LDAP/squid_ldap_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/helpers/basic_auth/LDAP/squid_ldap_auth.c,v retrieving revision 1.2.8.10 retrieving revision 1.2.8.11 diff -u -r1.2.8.10 -r1.2.8.11 --- squid/helpers/basic_auth/LDAP/squid_ldap_auth.c 24 Dec 2003 16:21:35 -0000 1.2.8.10 +++ squid/helpers/basic_auth/LDAP/squid_ldap_auth.c 3 Jan 2004 11:12:45 -0000 1.2.8.11 @@ -72,25 +72,25 @@ #include #include #include -#ifdef _WIN32 +#ifdef _SQUID_MSWIN_ #define snprintf _snprintf #include #include - -#ifdef LDAP_VERSION3 -#if LDAP_VERSION == LDAP_VERSION2 -#undef LDAP_VERSION3 -#endif -#endif - #ifdef LDAP_VERSION3 #define LDAP_OPT_SUCCESS LDAP_SUCCESS +/* Some tricks to allow dynamic bind with ldap_start_tls_s entry point at + run time. + */ #undef ldap_start_tls_s #if LDAP_UNICODE -#define ldap_start_tls_s(l,s,c) ldap_start_tls_sW(l,NULL,NULL,s,c) +#define LDAP_START_TLS_S "ldap_start_tls_sW" +typedef WINLDAPAPI ULONG (LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlW *, IN PLDAPControlW *); #else -#define ldap_start_tls_s(l,s,c) ldap_start_tls_sA(l,NULL,NULL,s,c) +#define LDAP_START_TLS_S "ldap_start_tls_sA" +typedef WINLDAPAPI ULONG (LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *); #endif /* LDAP_UNICODE */ +PFldap_start_tls_s Win32_ldap_start_tls_s; +#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c) #endif /* LDAP_VERSION3 */ #else #include @@ -407,6 +407,23 @@ fprintf(stderr, "\tIf you need to bind as a user to perform searches then use the\n\t-D binddn -w bindpasswd or -D binddn -W secretfile options\n\n"); exit(1); } + +/* On windows ldap_start_tls_s is available starting from Windows XP, + so we need to bind at run-time with the function entry point + */ +#ifdef _SQUID_MSWIN_ + if (use_tls) { + + HMODULE WLDAP32Handle; + + WLDAP32Handle = GetModuleHandle("wldap32"); + if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { + fprintf( stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n"); + exit(1); + } + } +#endif + while (fgets(buf, 256, stdin) != NULL) { user = strtok(buf, " \r\n"); passwd = strtok(NULL, "\r\n"); Index: squid/helpers/external_acl/ldap_group/squid_ldap_group.c =================================================================== RCS file: /cvsroot/squid-sf//squid/helpers/external_acl/ldap_group/squid_ldap_group.c,v retrieving revision 1.1.6.9 retrieving revision 1.1.6.10 diff -u -r1.1.6.9 -r1.1.6.10 --- squid/helpers/external_acl/ldap_group/squid_ldap_group.c 24 Dec 2003 16:22:04 -0000 1.1.6.9 +++ squid/helpers/external_acl/ldap_group/squid_ldap_group.c 3 Jan 2004 11:13:01 -0000 1.1.6.10 @@ -41,21 +41,21 @@ #define snprintf _snprintf #include #include - -#ifdef LDAP_VERSION3 -#if LDAP_VERSION == LDAP_VERSION2 -#undef LDAP_VERSION3 -#endif -#endif - #ifdef LDAP_VERSION3 #define LDAP_OPT_SUCCESS LDAP_SUCCESS +/* Some tricks to allow dynamic bind with ldap_start_tls_s entry point at + run time. + */ #undef ldap_start_tls_s -#if NOLDAP_UNICODE -#define ldap_start_tls_s(l,s,c) ldap_start_tls_sW(l,NULL,NULL,s,c) +#if LDAP_UNICODE +#define LDAP_START_TLS_S "ldap_start_tls_sW" +typedef WINLDAPAPI ULONG (LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlW *, IN PLDAPControlW *); #else -#define ldap_start_tls_s(l,s,c) ldap_start_tls_sA(l,NULL,NULL,s,c) +#define LDAP_START_TLS_S "ldap_start_tls_sA" +typedef WINLDAPAPI ULONG (LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *); #endif /* LDAP_UNICODE */ +PFldap_start_tls_s Win32_ldap_start_tls_s; +#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c) #endif /* LDAP_VERSION3 */ #else #include @@ -450,6 +450,23 @@ fprintf(stderr, "\tIf you need to bind as a user to perform searches then use the\n\t-D binddn -w bindpasswd or -D binddn -W secretfile options\n\n"); exit(1); } + +/* On windows ldap_start_tls_s is available starting from Windows XP, + so we need to bind at run-time with the function entry point + */ +#ifdef _SQUID_MSWIN_ + if (use_tls) { + + HMODULE WLDAP32Handle; + + WLDAP32Handle = GetModuleHandle("wldap32"); + if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { + fprintf( stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n"); + exit(1); + } + } +#endif + while (fgets(buf, 256, stdin) != NULL) { char *tptr; int found = 0;