Skip to content

Commit 69a8b63

Browse files
heiglandreascmb69TimWolla
authored
Deprecate ldap_connect with two parameters (#5177)
* Deprecate ldap_connect with two parameters ldap_connect should be called with an LDAP-URI as parameter and not with 2 parameters as that allows much more flexibility like differentiating between ldap and ldaps or setting multiple ldap-servers. This change requires one to add null as second parameter in case the underlying library is Oracle and one wants to add wallet-details. * Modify all ldap-tests to use ldap_connect right All tests are using ldap_connect now with an URI and not with host and port as two separarte parameters. * Verify deprecation of ldap_connect w/h 2 params This adds a test to verify that calling ldap_connect with 2 parameters triggers a deprecation notice * Remove empty test `ldap_control_paged_result()` is removed as of PHP 8.0.0, so this test needs to be removed as well. Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de> Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
1 parent 3d944a3 commit 69a8b63

File tree

101 files changed

+195
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+195
-178
lines changed

ext/ldap/ldap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,10 @@ PHP_FUNCTION(ldap_connect)
926926
ldap_linkdata *ld;
927927
LDAP *ldap = NULL;
928928

929+
if (ZEND_NUM_ARGS() == 2) {
930+
zend_error(E_DEPRECATED, "Usage of ldap_connect with two arguments is deprecated");
931+
}
932+
929933
#ifdef HAVE_ORALDAP
930934
if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
931935
WRONG_PARAM_COUNT;

ext/ldap/tests/bug48441.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require_once('skipifbindfailure.inc');
1212
<?php
1313
include "connect.inc";
1414

15-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
15+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
1616
insert_dummy_data($link, $base);
1717

1818
$dn = "$base";
@@ -35,7 +35,7 @@ var_dump(
3535
<?php
3636
include "connect.inc";
3737

38-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
38+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
3939
remove_dummy_data($link, $base);
4040
?>
4141
--EXPECTF--

ext/ldap/tests/bug73933.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ldap
55
--FILE--
66
<?php
77
/* We are assuming 3333 is not connectable */
8-
$ldap = ldap_connect('127.0.0.1', 3333);
8+
$ldap = ldap_connect('ldap://127.0.0.1:3333');
99

1010
ldap_mod_replace($ldap, '', array(
1111
'lockoutTime' => array(0),

ext/ldap/tests/bug77958.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ldap
1010
<?php
1111
require "connect.inc";
1212

13-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
13+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
1414
insert_dummy_data($link, $base);
1515

1616
$mods = array(
@@ -37,7 +37,7 @@ var_dump(
3737
<?php
3838
require "connect.inc";
3939

40-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
40+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
4141

4242
remove_dummy_data($link, $base);
4343
?>

ext/ldap/tests/connect.inc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Change the LDAP_TEST_* environment values if you want to use another configurati
77

88
$host = getenv("LDAP_TEST_HOST") ?: "localhost";
99
$port = getenv("LDAP_TEST_PORT") ?: 389;
10+
$uri = getenv("LDAP_TEST_URI") ?: 'ldap://localhost:389';
1011
$base = getenv("LDAP_TEST_BASE") ?: "dc=my-domain,dc=com";
1112
$user = getenv("LDAP_TEST_USER") ?: "cn=Manager,$base";
1213
$passwd = getenv("LDAP_TEST_PASSWD") ?: "secret";
@@ -15,15 +16,15 @@ $sasl_passwd = getenv("LDAP_TEST_SASL_PASSWD") ?: "oops";
1516
$protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ?: 3;
1617
$skip_on_bind_failure = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ?: true;
1718

18-
function ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version) {
19-
$link = ldap_connect($host, $port);
19+
function ldap_connect_and_bind($uri, $user, $passwd, $protocol_version) {
20+
$link = ldap_connect($uri);
2021
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
2122
ldap_bind($link, $user, $passwd);
2223
return $link;
2324
}
2425

25-
function test_bind($host, $port, $user, $passwd, $protocol_version) {
26-
$link = ldap_connect($host, $port);
26+
function test_bind($uri, $user, $passwd, $protocol_version) {
27+
$link = ldap_connect($uri);
2728
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
2829
return ldap_bind($link, $user, $passwd);
2930
}

ext/ldap/tests/ldap_add_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ldap
1111
<?php
1212
require "connect.inc";
1313

14-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
14+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
1515

1616
var_dump(
1717
ldap_add($link, "dc=my-domain,$base", array(
@@ -32,7 +32,7 @@ var_dump(
3232
<?php
3333
require "connect.inc";
3434

35-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
35+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
3636

3737
ldap_delete($link, "dc=my-domain,$base");
3838
?>

ext/ldap/tests/ldap_add_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ldap
1111
<?php
1212
require "connect.inc";
1313

14-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
14+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
1515

1616
var_dump(ldap_add($link, "$base", array()));
1717

@@ -86,7 +86,7 @@ var_dump(
8686
<?php
8787
require "connect.inc";
8888

89-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
89+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
9090

9191
ldap_delete($link, "dc=my-domain,$base");
9292
?>

ext/ldap/tests/ldap_add_ext.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ skipifunsupportedcontrol(LDAP_CONTROL_POST_READ);
1414
<?php
1515
require "connect.inc";
1616

17-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
17+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
1818

1919
var_dump(
2020
$result = ldap_add_ext($link, "o=test_ldap_add_ext,$base", array(
@@ -37,7 +37,7 @@ var_dump(
3737
<?php
3838
require "connect.inc";
3939

40-
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
40+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
4141

4242
ldap_delete($link, "o=test_ldap_add_ext,$base");
4343
?>

ext/ldap/tests/ldap_bind_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ldap
1111
<?php
1212
require "connect.inc";
1313

14-
$link = ldap_connect($host, $port);
14+
$link = ldap_connect($uri);
1515
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
1616
var_dump(ldap_bind($link));
1717
?>

ext/ldap/tests/ldap_bind_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ldap
1111
<?php
1212
require "connect.inc";
1313

14-
$link = ldap_connect($host, $port);
14+
$link = ldap_connect($uri);
1515
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
1616

1717
// Invalid password

0 commit comments

Comments
 (0)