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