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 parameter count 22var_dump(ldap_sasl_bind()); 23 24// Invalid DN 25var_dump(ldap_sasl_bind($link, "Invalid DN", $sasl_passwd, 'DIGEST-MD5', 'realm', $sasl_user)); 26 27// Invalid user 28var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", "invalid$sasl_user")); 29 30// Invalid password 31var_dump(ldap_sasl_bind($link, null, "ThisIsNotCorrect$sasl_passwd", 'DIGEST-MD5', "realm", $sasl_user)); 32 33var_dump(ldap_sasl_bind($link, null, $sasl_passwd, 'DIGEST-MD5', "realm", "Manager", "test")); 34 35// Invalid DN syntax 36var_dump(ldap_sasl_bind($link, "unexistingProperty=weirdValue,$user", $sasl_passwd)); 37?> 38===DONE=== 39--CLEAN-- 40<?php 41include "connect.inc"; 42 43$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); 44remove_dummy_data($link, $base); 45?> 46--EXPECTF-- 47Warning: ldap_sasl_bind() expects at least 1 parameter, 0 given in %s on line %d 48bool(false) 49 50Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d 51bool(false) 52 53Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d 54bool(false) 55 56Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d 57bool(false) 58 59Warning: ldap_sasl_bind(): Unable to bind to server: Insufficient access in %s on line %d 60bool(false) 61 62Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d 63bool(false) 64===DONE=== 65