Bug #79032 [Opn]: ldap_count_entries returns NULL not FALSE
| From: | admin at feministwiki dot org | Date: | Wed, 25 Dec 2019 15:38:40 +0000 |
| Subject: | Bug #79032 [Opn]: ldap_count_entries returns NULL not FALSE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224530@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79032&edit=1
ID: 79032
User updated by: admin at feministwiki dot org
Reported by: admin at feministwiki dot org
Summary: ldap_count_entries returns NULL not FALSE
Status: Open
Type: Bug
Package: LDAP related
Operating System: Ubuntu 16.04 LTS
PHP Version: 7.4.1
Block user comment: N
Private report: N
New Comment:
Just a note: the expression 'cn=$newUsername' should of course be
"cn=$newUsername" in my test script, although this makes no difference to the bug report.
Previous Comments:
------------------------------------------------------------------------
[2019-12-25 15:30:39] admin at feministwiki dot org
Description:
------------
---
From manual page: https://php.net/function.ldap-count-entries
---
When you forget to provide the first argument to ldap_count_entries (i.e. the link to the LDAP
connection), it returns NULL instead of FALSE.
As per documentation and consistency with other LDAP functions, it should return FALSE to indicate
an error.
Test script:
---------------
$ldapLink = ldap_connect('localhost');
ldap_set_option($ldapLink, LDAP_OPT_PROTOCOL_VERSION, 3);
$memberBase = "ou=members,dc=feministwiki,dc=org";
$userDN = "cn=testuser,$memberBase";
$newUsername = 'whatever';
ldap_bind($ldapLink, $userDN, '[REDACTED]');
$result = ldap_search($ldapLink, $memberBase, 'cn=$newUsername', array());
var_dump(ldap_count_entries($result)); # First argument missing.
Expected result:
----------------
The function should return FALSE to indicate an error, as per documentation and consistency with
other LDAP functions.
Actual result:
--------------
The function returns NULL.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79032&edit=1