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