#50185 [Opn->Fbk]: ldap_get_entries() return false instead of an empty array when there is no error

From: Date: Mon, 16 Nov 2009 09:38:25 +0000
Subject: #50185 [Opn->Fbk]: ldap_get_entries() return false instead of an empty array when there is no error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-144657@lists.php.net to get a copy of this message
ID: 50185 Updated by: jani@php.net -Summary: ldap-get-entries return false instead of an empty array when there is no error Reported By: Joel dot Brogniart at univ-lyon2 dot fr -Status: Open +Status: Feedback Bug Type: LDAP related Operating System: Mac OS X 10.5.8 PHP Version: 5.2.11 New Comment: RTFM: "Returns a complete result information in a multi-dimensional array on success and FALSE on error. " Your query most likely has an error, try check it with ldap_error() Previous Comments: ------------------------------------------------------------------------ [2009-11-16 08:50:07] Joel dot Brogniart at univ-lyon2 dot fr Description: ------------ With PHP version < 5.2.10, if the "bad_uid" is not in the LDAP directory and no error occured the following code return an empty array in $info. With PHP version 5.2.10 it return FALSE $info even when there is no error. (simplified code) $ldap_host="ldap.example.com"; $ldap_root="ou=people,dc=example,dc=com"; $ldap_dn="cn=admin,ou=people,dc=example,dc=com"; $ldap_password="fak3pwd"; $result = array(); $attribute_list = array("uid"); $connection = ldap_connect($ldap_host); $link = @ldap_bind($connection, $ldap_dn, $ldap_password); $search="(uid=bad_uid)"; $search_result = ldap_search($connection, $ldap_root, $search, $attribute_list); $info = ldap_get_entries($connection, $search_result); Reproduce code: --------------- --- From manual page: function.ldap-get-entries#Return Values --- $ldap_host="ldap.example.com"; $ldap_root="ou=people,dc=example,dc=com"; $ldap_dn="cn=admin,ou=people,dc=example,dc=com"; $ldap_password="fak3pwd"; $result = array(); $attribute_list = array("uid"); $connection = ldap_connect($ldap_host); $link = @ldap_bind($connection, $ldap_dn, $ldap_password); $search="(uid=bad_uid)"; $search_result = ldap_search($connection, $ldap_root, $search, $attribute_list); $info = ldap_get_entries($connection, $search_result); Expected result: ---------------- $info : Array ( ) Actual result: -------------- $info : ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50185&edit=1

« previous php.bugs (#144657) next »