1--TEST--
2ldap_search() - operation that should fail
3--CREDITS--
4Davide Mendolia <idaf1er@gmail.com>
5Belgian PHP Testfest 2009
6--EXTENSIONS--
7ldap
8--SKIPIF--
9<?php require_once __DIR__ .'/skipifbindfailure.inc'; ?>
10--FILE--
11<?php
12include "connect.inc";
13
14$link = ldap_connect($host, $port);
15
16$dn = "dc=not-found,$base";
17$filter = "(dc=*)";
18
19$result = ldap_search($link, $dn, $filter);
20var_dump($result);
21
22$result = ldap_search($link, $dn, $filter, array(1 => 'top'));
23var_dump($result);
24
25try {
26    ldap_search(array(), $dn, $filter, array('top'));
27} catch (ValueError $exception) {
28    echo $exception->getMessage() . "\n";
29}
30
31try {
32    ldap_search(array($link, $link), array($dn), $filter, array('top'));
33} catch (ValueError $exception) {
34    echo $exception->getMessage() . "\n";
35}
36
37try {
38    ldap_search(array($link, $link), $dn, array($filter), array('top'));
39} catch (ValueError $exception) {
40    echo $exception->getMessage() . "\n";
41}
42
43try {
44    ldap_search($link, [], []);
45} catch (TypeError $exception) {
46    echo $exception->getMessage() . "\n";
47}
48
49try {
50    ldap_search($link, "", []);
51} catch (TypeError $exception) {
52    echo $exception->getMessage() . "\n";
53}
54
55?>
56--EXPECTF--
57Warning: ldap_search(): Search: No such object in %s on line %d
58bool(false)
59
60Warning: ldap_search(): Array initialization wrong in %s on line %d
61bool(false)
62ldap_search(): Argument #1 ($ldap) cannot be empty
63ldap_search(): Argument #2 ($base) must have the same number of elements as the links array
64ldap_search(): Argument #3 ($filter) must have the same number of elements as the links array
65ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP instance
66ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP instance
67