diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 119e942d5a4..265b03ced8b 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -2017,7 +2017,7 @@ PHP_FUNCTION(ldap_start_tls) { zval **link; ldap_linkdata *ld; - int rc; + int rc, protocol = LDAP_VERSION3; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &link) == FAILURE) { WRONG_PARAM_COUNT; @@ -2025,7 +2025,9 @@ PHP_FUNCTION(ldap_start_tls) ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link); - if ((rc = ldap_start_tls_s(ld->link, NULL, NULL)) != LDAP_SUCCESS) { + if (((rc = ldap_set_option(ld->link, LDAP_OPT_PROTOCOL_VERSION, &protocol)) != LDAP_SUCCESS) || + ((rc = ldap_start_tls_s(ld->link, NULL, NULL)) != LDAP_SUCCESS) + ) { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unable to start TLS: %s", ldap_err2string(rc)); RETURN_FALSE; } else {