1--TEST--
2ldap_first_reference() - Basic ldap_first_reference test
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--EXTENSIONS--
7ldap
8--SKIPIF--
9<?php require_once('skipifbindfailure.inc'); ?>
10--FILE--
11<?php
12require "connect.inc";
13$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
14insert_dummy_data($link, $base);
15ldap_add($link, "cn=userref,$base", array(
16        "objectClass" => array("extensibleObject", "referral"),
17        "cn" => "userref",
18        "ref" => "cn=userA,$base",
19));
20ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
21$result = ldap_search($link, "$base", "(cn=*)");
22var_dump($ref = ldap_first_reference($link, $result));
23$refs = null;
24ldap_parse_reference($link, $ref, $refs);
25var_dump($refs);
26?>
27--CLEAN--
28<?php
29include "connect.inc";
30
31$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
32// Referral can only be removed with Manage DSA IT Control
33ldap_delete($link, "cn=userref,$base", [['oid' => LDAP_CONTROL_MANAGEDSAIT, 'iscritical' => TRUE]]);
34remove_dummy_data($link, $base);
35?>
36--EXPECTF--
37object(LDAP\ResultEntry)#%d (0) {
38}
39array(1) {
40  [0]=>
41  string(%d) "cn=userA,%s"
42}
43