diff -uNr proftpd-1.2.10/contrib/mod_ldap.c proftpd-1.2.10.new/contrib/mod_ldap.c --- proftpd-1.2.10/contrib/mod_ldap.c 2004-07-22 10:11:22.000000000 +1000 +++ proftpd-1.2.10.new/contrib/mod_ldap.c 2005-10-30 18:18:43.000000000 +1100 @@ -236,9 +236,7 @@ pr_ldap_connect(void) { int ret; -#ifdef USE_LDAPV3_TLS int version = LDAP_VERSION3; -#endif if ((ld = ldap_init(ldap_server, LDAP_PORT)) == NULL) { pr_log_pri(PR_LOG_ERR, "mod_ldap: pr_ldap_connect(): ldap_init() to %s failed: %s", ldap_server, strerror(errno)); @@ -262,6 +260,11 @@ } #endif /* USE_LDAPV3_TLS */ + if ((ret = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_OPT_SUCCESS) { + pr_log_pri(PR_LOG_ERR, "mod_ldap: pr_ldap_connect(): Setting LDAP version option failed: %s", ldap_err2string(ret)); + pr_ldap_unbind(); + return -1; + } if ((ret = ldap_simple_bind_s(ld, ldap_dn, ldap_dnpass) != LDAP_SUCCESS)) { pr_log_pri(PR_LOG_ERR, "mod_ldap: pr_ldap_connect(): ldap_simple_bind() as %s failed: %s", ldap_dn, ldap_err2string(ret)); return -1; @@ -1204,9 +1207,7 @@ char *pass, *cryptpass, *hash_method; int encname_len; LDAP *ld_auth; -#ifdef USE_LDAPV3_TLS int ret, version = LDAP_VERSION3; -#endif #ifdef HAVE_OPENSSL EVP_MD_CTX EVP_Context; @@ -1252,6 +1253,12 @@ } #endif /* USE_LDAPV3_TLS */ + if ((ret = ldap_set_option(ld_auth, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_OPT_SUCCESS) { + pr_log_pri(PR_LOG_ERR, "mod_ldap: pr_ldap_connect(): Setting LDAP version option on rebind failed: %s", ldap_err2string(ret)); + pr_ldap_unbind(); + return ERROR(cmd); + } + if (ldap_simple_bind_s(ld_auth, ldap_authbind_dn, cmd->argv[2]) != LDAP_SUCCESS) { ldap_unbind(ld_auth); return ERROR(cmd);