xref: /PHP-8.0/ext/ldap/tests/ldap_rename_ext.phpt (revision f8d79582)
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--CLEAN--
37<?php
38require "connect.inc";
39
40$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
41ldap_rename($link, "cn=userZ,$base", "cn=userA", "$base", true);
42remove_dummy_data($link, $base);
43?>
44--EXPECTF--
45resource(%d) of type (ldap result)
46bool(true)
47int(0)
48string(0) ""
49array(2) {
50  ["oid"]=>
51  string(14) "1.3.6.1.1.13.1"
52  ["value"]=>
53  array(2) {
54    ["dn"]=>
55    string(%d) "cn=userA,%s"
56    ["cn"]=>
57    array(1) {
58      [0]=>
59      string(5) "userA"
60    }
61  }
62}
63array(2) {
64  ["oid"]=>
65  string(14) "1.3.6.1.1.13.2"
66  ["value"]=>
67  array(2) {
68    ["dn"]=>
69    string(%d) "cn=userZ,%s"
70    ["cn"]=>
71    array(1) {
72      [0]=>
73      string(5) "userZ"
74    }
75  }
76}
77int(0)
78int(1)
79