1--TEST--
2ldap_sasl_bind() - Binding that should fail
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 if (!function_exists("ldap_sasl_bind")) die("skip LDAP extension not compiled with SASL support"); ?>
10--FILE--
11<?php
12require "connect.inc";
13
14$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
15insert_dummy_data($link, $base);
16ldap_unbind($link);
17
18$link = ldap_connect($host, $port);
19ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
20
21// Invalid DN
22var_dump(ldap_sasl_bind($link, "Invalid DN", $sasl_passwd, 'DIGEST-MD5', 'realm', $sasl_user));
23
24// Invalid user
25var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", "invalid$sasl_user"));
26
27// Invalid password
28var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", $sasl_user));
29
30var_dump(ldap_sasl_bind($link, null, $sasl_passwd, 'DIGEST-MD5', "realm", "Manager", "test"));
31
32// Invalid DN syntax
33var_dump(ldap_sasl_bind($link, "unexistingProperty=weirdValue,$user", $sasl_passwd));
34?>
35--CLEAN--
36<?php
37include "connect.inc";
38
39$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
40remove_dummy_data($link, $base);
41?>
42--EXPECTF--
43Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d
44bool(false)
45
46Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d
47bool(false)
48
49Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d
50bool(false)
51
52Warning: ldap_sasl_bind(): Unable to bind to server: Insufficient access in %s on line %d
53bool(false)
54
55Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d
56bool(false)
57