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