diff options
author | Côme Bernigaud <mcmic@php.net> | 2017-05-30 16:45:27 +0200 |
---|---|---|
committer | Côme Bernigaud <mcmic@php.net> | 2017-05-30 16:45:27 +0200 |
commit | dc7e53690faf7cc694f1278e43314414080d75f6 (patch) | |
tree | e98743e5347079705fc7d7321f14dd79be8d9933 | |
parent | 46bb35a853e5dbb9cc7f9ca87ad5c3ca5d728750 (diff) | |
parent | 49d1cdc3937caeace454bfed74b3f758bc76b826 (diff) | |
download | php-git-dc7e53690faf7cc694f1278e43314414080d75f6.tar.gz |
Merge branch 'pull-request/2536' into PHP-7.0
* pull-request/2536:
ext/ldap/test: Test that ldap_connect() uses defaults from ldap.conf (openldap)
ext/ldap: Allow default host from ldap.conf to work.
-rw-r--r-- | ext/ldap/ldap.c | 4 | ||||
-rw-r--r-- | ext/ldap/tests/ldap_connect_ldap_conf.phpt | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 109508bbbe..cec20da3cc 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -366,7 +366,7 @@ PHP_FUNCTION(ldap_connect) { int rc = LDAP_SUCCESS; char *url = host; - if (!ldap_is_ldap_url(url)) { + if (url && !ldap_is_ldap_url(url)) { int urllen = hostlen + sizeof( "ldap://:65535" ); if (port <= 0 || port > 65535) { @@ -376,7 +376,7 @@ PHP_FUNCTION(ldap_connect) } url = emalloc(urllen); - snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port ); + snprintf( url, urllen, "ldap://%s:%ld", host, port ); } #ifdef LDAP_API_FEATURE_X_OPENLDAP diff --git a/ext/ldap/tests/ldap_connect_ldap_conf.phpt b/ext/ldap/tests/ldap_connect_ldap_conf.phpt new file mode 100644 index 0000000000..5379de4cb5 --- /dev/null +++ b/ext/ldap/tests/ldap_connect_ldap_conf.phpt @@ -0,0 +1,26 @@ +--TEST-- +ldap_connect() - Connection using default host from openldap's ldap.conf +--CREDITS-- +David Caldwell <david@galvanix.com> +--SKIPIF-- +<?php +require_once('skipif.inc'); +ob_start(); +phpinfo(); +if (!preg_match("/vendor name => openldap/i", ob_get_clean())) + die("skip not openldap"); +?> +--FILE-- +<?php +$conf=tempnam("/tmp","ldap.conf"); +file_put_contents($conf, "uri ldaps://example.com:3141/"); +putenv("LDAPCONF=$conf"); +$link = ldap_connect(); +ldap_get_option($link, LDAP_OPT_HOST_NAME, $host); +var_dump($host); +unlink($conf); +?> +===DONE=== +--EXPECTF-- +string(16) "example.com:3141" +===DONE=== |