xref: /PHP-8.3/ext/ldap/tests/ldap_mod_ext.phpt (revision 69a8b63e)
1--TEST--
2ldap_mod_ext() - Modify operations with controls
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--EXTENSIONS--
7ldap
8--SKIPIF--
9<?php require_once('skipifbindfailure.inc'); ?>
10<?php
11require_once('skipifcontrol.inc');
12skipifunsupportedcontrol(LDAP_CONTROL_PRE_READ);
13skipifunsupportedcontrol(LDAP_CONTROL_POST_READ);
14?>
15--FILE--
16<?php
17require "connect.inc";
18
19$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
20insert_dummy_data($link, $base);
21
22$entry = array(
23    "description"	=> "Domain description",
24);
25
26var_dump(
27    $result = ldap_mod_add_ext($link, "o=test,$base", $entry,
28        [
29            ['oid' => LDAP_CONTROL_PRE_READ,  'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
30            ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
31        ]
32    ),
33    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
34    $errcode,
35    $errmsg,
36    $ctrls,
37    ldap_get_entries(
38        $link,
39        ldap_search($link, "o=test,$base", "(Description=Domain description)")
40    ),
41    $result = ldap_mod_del_ext($link, "o=test,$base", $entry,
42        [
43            ['oid' => LDAP_CONTROL_PRE_READ,  'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
44            ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]],
45        ]
46    ),
47    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
48    $errcode,
49    $errmsg,
50    $ctrls,
51    ldap_get_entries(
52        $link,
53        ldap_search($link, "o=test,$base", "(Description=Domain description)")
54    )
55);
56?>
57--CLEAN--
58<?php
59require "connect.inc";
60
61$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
62
63remove_dummy_data($link, $base);
64?>
65--EXPECTF--
66object(LDAP\Result)#%d (0) {
67}
68bool(true)
69int(0)
70string(0) ""
71array(2) {
72  ["1.3.6.1.1.13.1"]=>
73  array(2) {
74    ["oid"]=>
75    string(14) "1.3.6.1.1.13.1"
76    ["value"]=>
77    array(1) {
78      ["dn"]=>
79      string(%d) "o=test,%s"
80    }
81  }
82  ["1.3.6.1.1.13.2"]=>
83  array(2) {
84    ["oid"]=>
85    string(14) "1.3.6.1.1.13.2"
86    ["value"]=>
87    array(2) {
88      ["dn"]=>
89      string(%d) "o=test,%s"
90      ["description"]=>
91      array(1) {
92        [0]=>
93        string(18) "Domain description"
94      }
95    }
96  }
97}
98array(2) {
99  ["count"]=>
100  int(1)
101  [0]=>
102  array(8) {
103    ["objectclass"]=>
104    array(3) {
105      ["count"]=>
106      int(2)
107      [0]=>
108      string(3) "top"
109      [1]=>
110      string(12) "organization"
111    }
112    [0]=>
113    string(11) "objectclass"
114    ["o"]=>
115    array(2) {
116      ["count"]=>
117      int(1)
118      [0]=>
119      string(4) "test"
120    }
121    [1]=>
122    string(1) "o"
123    ["description"]=>
124    array(2) {
125      ["count"]=>
126      int(1)
127      [0]=>
128      string(18) "Domain description"
129    }
130    [2]=>
131    string(11) "description"
132    ["count"]=>
133    int(3)
134    ["dn"]=>
135    string(%d) "o=test,%s"
136  }
137}
138object(LDAP\Result)#%d (0) {
139}
140bool(true)
141int(0)
142string(0) ""
143array(2) {
144  ["1.3.6.1.1.13.1"]=>
145  array(2) {
146    ["oid"]=>
147    string(14) "1.3.6.1.1.13.1"
148    ["value"]=>
149    array(2) {
150      ["dn"]=>
151      string(%d) "o=test,%s"
152      ["description"]=>
153      array(1) {
154        [0]=>
155        string(18) "Domain description"
156      }
157    }
158  }
159  ["1.3.6.1.1.13.2"]=>
160  array(2) {
161    ["oid"]=>
162    string(14) "1.3.6.1.1.13.2"
163    ["value"]=>
164    array(1) {
165      ["dn"]=>
166      string(%d) "o=test,%s"
167    }
168  }
169}
170array(1) {
171  ["count"]=>
172  int(0)
173}
174