Skip to content

Commit cc7140e

Browse files
author
Côme Bernigaud
committed
Merge branch 'pull-request/1512' into PHP-5.5
* pull-request/1512: Fix bug in LDAP extensions' saving TIMELIMIT and DEREF
2 parents bb98ed6 + c3fc65e commit cc7140e

File tree

2 files changed

+217
-2
lines changed

2 files changed

+217
-2
lines changed

ext/ldap/ldap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
600600
/* timelimit */
601601
if (timelimit > -1) {
602602
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP
603-
ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_timelimit);
603+
ldap_get_option(ldap, LDAP_OPT_TIMELIMIT, old_timelimit);
604604
ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
605605
#else
606606
*old_timelimit = ldap->ld_timelimit;
@@ -611,7 +611,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
611611
/* deref */
612612
if (deref > -1) {
613613
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP
614-
ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_deref);
614+
ldap_get_option(ldap, LDAP_OPT_DEREF, old_deref);
615615
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
616616
#else
617617
*old_deref = ldap->ld_deref;
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
--TEST--
2+
ldap_search() test - test that overrides aren't permanent
3+
--CREDITS--
4+
Tyson Andre <tandre@ifwe.co>
5+
# Based on ldap_search_basic.phpt
6+
--SKIPIF--
7+
<?php
8+
require_once('skipif.inc');
9+
require_once('skipifbindfailure.inc');
10+
?>
11+
--FILE--
12+
<?php
13+
include "connect.inc";
14+
15+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
16+
ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_SEARCHING);
17+
ldap_set_option($link, LDAP_OPT_SIZELIMIT, 123);
18+
ldap_set_option($link, LDAP_OPT_TIMELIMIT, 33);
19+
ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, 44);
20+
21+
insert_dummy_data($link, $base);
22+
var_dump(
23+
$result = ldap_search($link, "$base", "(objectClass=person)", array(), null, 111, 22, LDAP_DEREF_NEVER),
24+
ldap_get_entries($link, $result)
25+
);
26+
var_dump(
27+
ldap_get_option($link, LDAP_OPT_DEREF, $option),
28+
$option,
29+
ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option),
30+
$option,
31+
ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option),
32+
$option,
33+
ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option),
34+
$option
35+
);
36+
?>
37+
===DONE===
38+
--CLEAN--
39+
<?php
40+
include "connect.inc";
41+
42+
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
43+
remove_dummy_data($link, $base);
44+
?>
45+
--EXPECTF--
46+
resource(%d) of type (ldap result)
47+
array(4) {
48+
["count"]=>
49+
int(3)
50+
[0]=>
51+
array(14) {
52+
["objectclass"]=>
53+
array(2) {
54+
["count"]=>
55+
int(1)
56+
[0]=>
57+
string(6) "person"
58+
}
59+
[0]=>
60+
string(11) "objectclass"
61+
["cn"]=>
62+
array(2) {
63+
["count"]=>
64+
int(1)
65+
[0]=>
66+
string(5) "userA"
67+
}
68+
[1]=>
69+
string(2) "cn"
70+
["sn"]=>
71+
array(2) {
72+
["count"]=>
73+
int(1)
74+
[0]=>
75+
string(7) "testSN1"
76+
}
77+
[2]=>
78+
string(2) "sn"
79+
["userpassword"]=>
80+
array(2) {
81+
["count"]=>
82+
int(1)
83+
[0]=>
84+
string(4) "oops"
85+
}
86+
[3]=>
87+
string(12) "userpassword"
88+
["telephonenumber"]=>
89+
array(2) {
90+
["count"]=>
91+
int(1)
92+
[0]=>
93+
string(14) "xx-xx-xx-xx-xx"
94+
}
95+
[4]=>
96+
string(15) "telephonenumber"
97+
["description"]=>
98+
array(2) {
99+
["count"]=>
100+
int(1)
101+
[0]=>
102+
string(6) "user A"
103+
}
104+
[5]=>
105+
string(11) "description"
106+
["count"]=>
107+
int(6)
108+
["dn"]=>
109+
string(%d) "cn=userA,%s"
110+
}
111+
[1]=>
112+
array(12) {
113+
["objectclass"]=>
114+
array(2) {
115+
["count"]=>
116+
int(1)
117+
[0]=>
118+
string(6) "person"
119+
}
120+
[0]=>
121+
string(11) "objectclass"
122+
["cn"]=>
123+
array(2) {
124+
["count"]=>
125+
int(1)
126+
[0]=>
127+
string(5) "userB"
128+
}
129+
[1]=>
130+
string(2) "cn"
131+
["sn"]=>
132+
array(2) {
133+
["count"]=>
134+
int(1)
135+
[0]=>
136+
string(7) "testSN2"
137+
}
138+
[2]=>
139+
string(2) "sn"
140+
["userpassword"]=>
141+
array(2) {
142+
["count"]=>
143+
int(1)
144+
[0]=>
145+
string(15) "oopsIDitItAgain"
146+
}
147+
[3]=>
148+
string(12) "userpassword"
149+
["description"]=>
150+
array(2) {
151+
["count"]=>
152+
int(1)
153+
[0]=>
154+
string(6) "user B"
155+
}
156+
[4]=>
157+
string(11) "description"
158+
["count"]=>
159+
int(5)
160+
["dn"]=>
161+
string(%d) "cn=userB,%s"
162+
}
163+
[2]=>
164+
array(10) {
165+
["objectclass"]=>
166+
array(2) {
167+
["count"]=>
168+
int(1)
169+
[0]=>
170+
string(6) "person"
171+
}
172+
[0]=>
173+
string(11) "objectclass"
174+
["cn"]=>
175+
array(2) {
176+
["count"]=>
177+
int(1)
178+
[0]=>
179+
string(5) "userC"
180+
}
181+
[1]=>
182+
string(2) "cn"
183+
["sn"]=>
184+
array(2) {
185+
["count"]=>
186+
int(1)
187+
[0]=>
188+
string(7) "testSN3"
189+
}
190+
[2]=>
191+
string(2) "sn"
192+
["userpassword"]=>
193+
array(2) {
194+
["count"]=>
195+
int(1)
196+
[0]=>
197+
string(17) "0r1g1na1 passw0rd"
198+
}
199+
[3]=>
200+
string(12) "userpassword"
201+
["count"]=>
202+
int(4)
203+
["dn"]=>
204+
string(%d) "cn=userC,cn=userB,%s"
205+
}
206+
}
207+
bool(true)
208+
int(1)
209+
bool(true)
210+
int(123)
211+
bool(true)
212+
int(33)
213+
bool(true)
214+
int(44)
215+
===DONE===

0 commit comments

Comments
 (0)