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