xref: /PHP-7.3/ext/ldap/tests/ldap_rename_ext.phpt (revision 76e9de68)
1--TEST--
2ldap_rename_ext() - Rename operation with controls
3--CREDITS--
4Côme Chilliet <mcmic@php.net>
5--SKIPIF--
6<?php require_once('skipif.inc'); ?>
7<?php require_once('skipifbindfailure.inc'); ?>
8<?php
9require_once('skipifcontrol.inc');
10skipifunsupportedcontrol(LDAP_CONTROL_PRE_READ);
11skipifunsupportedcontrol(LDAP_CONTROL_POST_READ);
12?>
13--FILE--
14<?php
15require "connect.inc";
16
17$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
18insert_dummy_data($link, $base);
19
20var_dump(
21	$result = ldap_rename_ext($link, "cn=userA,$base", "cn=userZ", "$base", TRUE,
22		[
23			['oid' => LDAP_CONTROL_PRE_READ,  'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]],
24			['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]]
25		]
26	),
27	ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
28	$errcode,
29	$errmsg,
30	$ctrls[LDAP_CONTROL_PRE_READ],
31	$ctrls[LDAP_CONTROL_POST_READ],
32	ldap_count_entries($link, ldap_search($link, "$base", "(cn=userA)", array("cn"))),
33	ldap_count_entries($link, ldap_search($link, "$base", "(cn=userZ)", array("cn")))
34);
35?>
36===DONE===
37--CLEAN--
38<?php
39require "connect.inc";
40
41$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
42ldap_rename($link, "cn=userZ,$base", "cn=userA", "$base", true);
43remove_dummy_data($link, $base);
44?>
45--EXPECTF--
46resource(%d) of type (ldap result)
47bool(true)
48int(0)
49string(0) ""
50array(2) {
51  ["oid"]=>
52  string(14) "1.3.6.1.1.13.1"
53  ["value"]=>
54  array(2) {
55    ["dn"]=>
56    string(%d) "cn=userA,%s"
57    ["cn"]=>
58    array(1) {
59      [0]=>
60      string(5) "userA"
61    }
62  }
63}
64array(2) {
65  ["oid"]=>
66  string(14) "1.3.6.1.1.13.2"
67  ["value"]=>
68  array(2) {
69    ["dn"]=>
70    string(%d) "cn=userZ,%s"
71    ["cn"]=>
72    array(1) {
73      [0]=>
74      string(5) "userZ"
75    }
76  }
77}
78int(0)
79int(1)
80===DONE===
81