xref: /PHP-8.1/ext/ldap/tests/ldap_add_basic.phpt (revision 849a34e4)
1--TEST--
2ldap_add() - Basic add operation
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--EXTENSIONS--
7ldap
8--SKIPIF--
9<?php require_once('skipifbindfailure.inc'); ?>
10--FILE--
11<?php
12require "connect.inc";
13
14$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
15
16var_dump(
17    ldap_add($link, "dc=my-domain,$base", array(
18        "objectClass"	=> array(
19            "top",
20            "dcObject",
21            "organization"),
22        "dc"			=> "my-domain",
23        "o"				=> "my-domain",
24    )),
25    ldap_get_entries(
26        $link,
27        ldap_search($link, "$base", "(o=my-domain)")
28    )
29);
30?>
31--CLEAN--
32<?php
33require "connect.inc";
34
35$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
36
37ldap_delete($link, "dc=my-domain,$base");
38?>
39--EXPECTF--
40bool(true)
41array(2) {
42  ["count"]=>
43  int(1)
44  [0]=>
45  array(8) {
46    ["objectclass"]=>
47    array(4) {
48      ["count"]=>
49      int(3)
50      [0]=>
51      string(3) "top"
52      [1]=>
53      string(8) "dcObject"
54      [2]=>
55      string(12) "organization"
56    }
57    [0]=>
58    string(11) "objectclass"
59    ["dc"]=>
60    array(2) {
61      ["count"]=>
62      int(1)
63      [0]=>
64      string(9) "my-domain"
65    }
66    [1]=>
67    string(2) "dc"
68    ["o"]=>
69    array(2) {
70      ["count"]=>
71      int(1)
72      [0]=>
73      string(9) "my-domain"
74    }
75    [2]=>
76    string(1) "o"
77    ["count"]=>
78    int(3)
79    ["dn"]=>
80    string(%d) "dc=my-domain,%s"
81  }
82}
83