Edit report at https://bugs.php.net/bug.php?id=63299&edit=1

 ID:                 63299
 Updated by:         m...@php.net
 Reported by:        php at monona dot us
 Summary:            call to ldap_search returns null
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            LDAP related
 Operating System:   Windows
 PHP Version:        5.3.17
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2012-10-18 05:36:47] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63299&edit=1

Reply via email to