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($host, $port);
15ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
16
17// Invalid parameter count
18var_dump(ldap_sasl_bind());
19
20// Invalid DN
21var_dump(ldap_sasl_bind($link, "Invalid DN", $passwd, 'DIGEST-MD5', 'realm', $sasl_user));
22
23// Invalid user
24var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$passwd", 'DIGEST-MD5', "realm", "invalid$sasl_user"));
25
26// Invalid password
27var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$passwd", 'DIGEST-MD5', "realm", $sasl_user));
28
29var_dump(ldap_sasl_bind($link, null, $passwd, 'DIGEST-MD5', "realm", "Manager", "test"));
30
31// Invalid DN syntax
32var_dump(ldap_sasl_bind($link, "unexistingProperty=weirdValue,$user", $passwd));
33?>
34===DONE===
35--EXPECTF--
36Warning: ldap_sasl_bind() expects at least 1 parameter, 0 given in %s on line %d
37bool(false)
38
39Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d
40bool(false)
41
42Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d
43bool(false)
44
45Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d
46bool(false)
47
48Warning: ldap_sasl_bind(): Unable to bind to server: Insufficient access in %s on line %d
49bool(false)
50
51Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d
52bool(false)
53===DONE===
54