ID: 50185 User updated by: Joel dot Brogniart at univ-lyon2 dot fr Reported By: Joel dot Brogniart at univ-lyon2 dot fr -Status: Feedback +Status: Open Bug Type: LDAP related Operating System: Mac OS X 10.5.8 PHP Version: 5.2.11 New Comment:
Here is a transcript of an interactive PHP session (real user, server, password modified). server:~ johndoe$ php -v PHP 5.2.11 (cli) (built: Sep 28 2009 16:48:57) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies server:~ johndoe$ php -a Interactive mode enabled <?php $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"; $attribute_list = array("uid"); $connection = ldap_connect($ldap_host); printf("ldap_connect error:%s\n", ldap_errno($connection)); $link = @ldap_bind($connection, $ldap_dn, $ldap_password); printf("ldap_bind error:%s\n", ldap_errno($connection)); $search="(uid=bad_uid)"; $search_result = ldap_search($connection, $ldap_root, $search, $attribute_list); printf("ldap_search error:%s\n", ldap_errno($connection)); $info = ldap_get_entries($connection, $search_result); printf("ldap_get_entries error:%s\n", ldap_errno($connection)); printf("var_dump($info): "); var_dump($info); ?> ldap_connect error:0 ldap_bind error:0 ldap_search error:0 ldap_get_entries error:0 var_dump(): NULL Previous Comments: ------------------------------------------------------------------------ [2009-11-17 09:20:00] j...@php.net I'd be quite surprised if this func returned null in PHP 5.2.11 since there's only code to return FALSE. var_dump($info); to see what it is. ------------------------------------------------------------------------ [2009-11-17 05:27:29] Joel dot Brogniart at univ-lyon2 dot fr I confirm (and as stated in my description) that ldap-get-entries return NULL when there is no entries corresponding to the request filter even when there is no error. No error. And I too think that the new behavior comes from the change described at http://bugs.php.net/bug.php?id=48469. ------------------------------------------------------------------------ [2009-11-17 04:40:51] php at group dot apple dot com This behavior changed in 5.2.9, apparently due to the change associated with http://bugs.php.net/bug.php?id=48469 ------------------------------------------------------------------------ [2009-11-16 09:38:24] j...@php.net 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() ------------------------------------------------------------------------ [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