xref: /PHP-8.3/ext/ldap/tests/ldap_add_ext.phpt (revision 69a8b63e)
1--TEST--
2ldap_add_ext() - Add 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_POST_READ);
12?>
13--FILE--
14<?php
15require "connect.inc";
16
17$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
18
19var_dump(
20    $result = ldap_add_ext($link, "o=test_ldap_add_ext,$base", array(
21        "objectClass"	=> array(
22            "top",
23            "organization"),
24        "o"	=> "test_ldap_add_ext",
25    ), [['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['o']]]]),
26    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
27    $errcode,
28    $errmsg,
29    $ctrls[LDAP_CONTROL_POST_READ],
30    ldap_get_entries(
31        $link,
32        ldap_search($link, "$base", "(o=test_ldap_add_ext)")
33    )
34);
35?>
36--CLEAN--
37<?php
38require "connect.inc";
39
40$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
41
42ldap_delete($link, "o=test_ldap_add_ext,$base");
43?>
44--EXPECTF--
45object(LDAP\Result)#%d (0) {
46}
47bool(true)
48int(0)
49string(0) ""
50array(2) {
51  ["oid"]=>
52  string(14) "1.3.6.1.1.13.2"
53  ["value"]=>
54  array(2) {
55    ["dn"]=>
56    string(%d) "o=test_ldap_add_ext,%s"
57    ["o"]=>
58    array(1) {
59      [0]=>
60      string(17) "test_ldap_add_ext"
61    }
62  }
63}
64array(2) {
65  ["count"]=>
66  int(1)
67  [0]=>
68  array(6) {
69    ["objectclass"]=>
70    array(3) {
71      ["count"]=>
72      int(2)
73      [0]=>
74      string(3) "top"
75      [1]=>
76      string(12) "organization"
77    }
78    [0]=>
79    string(11) "objectclass"
80    ["o"]=>
81    array(2) {
82      ["count"]=>
83      int(1)
84      [0]=>
85      string(17) "test_ldap_add_ext"
86    }
87    [1]=>
88    string(1) "o"
89    ["count"]=>
90    int(2)
91    ["dn"]=>
92    string(%d) "o=test_ldap_add_ext,%s"
93  }
94}
95