php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63299 call to ldap_search returns null
Submitted: 2012-10-18 05:36 UTC Modified: 2013-09-30 09:48 UTC
From: php at monona dot us Assigned:
Status: Not a bug Package: LDAP related
PHP Version: 5.3.17 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at monona dot us
New email:
PHP Version: OS:

 

 [2012-10-18 05:36 UTC] php at monona dot us
Description:
------------
---
From manual page: http://www.php.net/function.ldap-search#refsect1-function.ldap-search-returnvalues
---
The documentation for function ldap_search says that it will either return a resource or it will return a boolean false.

I have successfully bound to a microsoft Active Directory using ldap_connect and ldap_bind. When I call ldap_search with a null for the forth parameter($attributes) it returns a null while setting ldap_error() to "Sucess" and ldap_errno() to zero.

The reason for passing a null for $attributes is so that I can explicity set a limit using the sixth parameter ($sizelimit) and because I want everything passed back, as if I had called ldap_search with only three parameters.

Another factor that probably contributes to creating this bug is that if I make the call to ldap_search with just 3 paramters, it returns false with error set to "Operations error" and errno set to 1 so there is obviously something else wrong with the search.

I would prefer that either this condition return false and a specific error message if there is something about the null $attributes that is an error or that it return false/1/Operations error because that error is in fact still true or that the documentation be updated to reflect when/why this function can return null/o/success when in fact there is nothing successful about the call.

Test script:
---------------
<?php
 // replace xxxxxx with your server name
 $ad=ldap_connect('ldap://xxxxxx');
 ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
 ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
 ldap_bind($ad);
 // replace xxxxxx etc. with your base DN
 $result=@ldap_search($ad,'dc=xxxxxx,dc=com','(objectClass=*)',null,1,10);
 if(!$result){
  die('Could not search AD because '.ldap_error($ad).'('.ldap_errno($ad).')');
 }
 ldap_unbind($ad);
?>


Expected result:
----------------
return false
ldap_error() returns 'Operation error'
ldap_error() errno=1

or

return false
ldap_error() returns 'Some message about invalid $attributes parameter'
ldap_errno() returnd unique error number for above

Actual result:
--------------
Return value of NULL
ldap_error() returns 'Success'
ldap_errno() returns 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-30 09:48 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-09-30 09:48 UTC] mike@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Remove the error suppression operator (@) and you'll most probably see an error message about wrong function arguments.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 04 00:01:30 2024 UTC