|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29895 connect via CLI failed
Submitted: 2004-08-30 12:58 UTC Modified: 2005-01-16 01:00 UTC
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: sonny at sun dot com Assigned:
Status: No Feedback Package: LDAP related
PHP Version: 4.3.8, 5.0.1 OS: Fedora Core 2
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.
Block user comment
Status: Assign to:
Bug Type:
From: sonny at sun dot com
New email:
PHP Version: OS:


 [2004-08-30 12:58 UTC] sonny at sun dot com
Just using a simple Script to try to connect to an LDAP Server. (see below)
If I execute this script via apache mod_php4 it works fine a I get an Resource Handle back.
But using CLI cause the same script an connection failed.
The same behavior is in php 5.0.1.
Module ldap is laoded via php.ini, because it's shared compliled.

Reproduce code:
$ld = ldap_connect("ldap.example,com", "389");

Expected result:
Working as well in CLI as well as module/SAPI.

Actual result:
Connect failed in CLI.
[root@pecl parser]$ php4 t.php 

Warning: ldap_close() expects parameter 1 to be resource, boolean given in t.php on line 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-01 10:01 UTC]
Do the openldap (assuming you're using openldap since you didn't say what you actually use) CLI tools work?
This might be some weird permission issue. Maybe the user as what you run the script doesn't have rights to read the ldap ini files or something alike. 

And have you tried to run it on command line while you have Apache running? (this shouldn't matter..but try run it when you've shutdown Apache)

 [2004-10-01 11:10 UTC] sonny at sun dot com
Yep I'm using standard openldap installation from Fedora.
Just checked if cli tools from openldap works .. YES.

Sample: ldapsearch -h -b dc=example,dc=com -s sub -p 389 employeenumber=tester -x
# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

I don't belive in a persission issue - while I have test the scripts as root.

While webserver was shutdown the same behavior - as expected. 

I have try to strace the programm an found this srange/error:
fstat64(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
lseek(4, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
dup(1)                                  = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lseek(5, 0, SEEK_CUR)                   = 0
dup(2)                                  = 6
fstat64(6, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
lseek(6, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)

Maybe this can help.
 [2004-10-01 11:14 UTC] sonny at sun dot com
Aditional info to strace:

read(3, "<?php\n\n$ld = ldap_connect(\'129.1"..., 8192) = 88
read(3, "", 4096)                       = 0
read(3, "", 8192)                       = 0
close(3)                                = 0
munmap(0xf6d4d000, 4096)                = 0
mmap2(NULL, 143360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf6d2a000
fcntl64(147436232, F_SETFD, FD_CLOEXEC) = -1 EBADF (Bad file descriptor)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf6d29000
write(1, "\n", 1
)                       = 1
write(1, "Warning: ldap_close() expects pa"..., 99Warning: ldap_close() expects parameter 1 to be resource, boolean given in /tmp/ldap.php on line 6
 [2004-12-12 16:20 UTC]
Try to trace it in GDB instead of strace..
Put a break for zif_ldap_connect call and step from there and show the result.

 [2004-12-20 14:20 UTC] sonny at sun dot com
Sorry for the late repsonce. I was in vacation.
I don't know how to handle gdb - so I try it to check it with other php verions.
Try 5.0.3 which have the same result while I have changed the configure option for ldap from shared to static.
Fails agian.
But strange with 5.0.2 it works with cli as well sapi.
The 4.3.x verions I haven't tried.
But I'll get while make install strange errors from PEAR.

Installing PEAR environment:      /usr/local/php5/lib/php/
[PEAR] Archive_Tar: XML error: not well-formed (invalid token) at line 22
[PEAR] Console_Getopt - installed: 1.2
[PEAR] PEAR: XML error: not well-formed (invalid token) at line 22
[PEAR] XML_RPC: XML error: not well-formed (invalid token) at line 11

Maybe can you give me here a hint.

 [2005-01-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 23:01:31 2024 UTC