xref: /PHP-8.0/ext/ldap/tests/ldap_bind_ext.phpt (revision f8d79582)
1--TEST--
2ldap_bind_ext() - Basic binding
3--CREDITS--
4Côme Chilliet <mcmic@php.net>
5--SKIPIF--
6<?php require_once __DIR__ .'/skipif.inc'; ?>
7<?php require_once __DIR__ .'/skipifbindfailure.inc'; ?>
8<?php
9require_once('skipifcontrol.inc');
10skipifunsupportedcontrol(LDAP_CONTROL_PASSWORDPOLICYREQUEST);
11?>
12--FILE--
13<?php
14require "connect.inc";
15
16$link = ldap_connect($host, $port);
17ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
18
19var_dump(
20    $result = ldap_bind_ext($link, $user, $passwd),
21    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
22    $errcode,
23    $errmsg,
24    $ctrls,
25    $result = ldap_bind_ext($link, $user, $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
26    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
27    $errcode,
28    $errmsg,
29    $ctrls
30);
31
32/* Failures */
33var_dump(
34    $result = ldap_bind_ext($link, $user, "wrongPassword", [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
35    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
36    $errcode,
37    $errmsg,
38    $ctrls,
39    $result = ldap_bind_ext($link, "unexistingProperty=weirdValue,$user", $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]),
40    ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls),
41    $errcode,
42    $errmsg,
43    $ctrls
44);
45?>
46--EXPECTF--
47resource(%d) of type (ldap result)
48bool(true)
49int(0)
50string(0) ""
51array(0) {
52}
53resource(%d) of type (ldap result)
54bool(true)
55int(0)
56string(0) ""
57array(0) {
58}
59resource(%d) of type (ldap result)
60bool(true)
61int(49)
62string(0) ""
63array(0) {
64}
65resource(%d) of type (ldap result)
66bool(true)
67int(34)
68string(10) "invalid DN"
69array(0) {
70}
71