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