|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72064 ldap_connect sees correct args as *uninitialized*
Submitted: 2016-04-20 13:48 UTC Modified: 2018-06-24 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: hcoin at quietfountain dot com Assigned:
Status: No Feedback Package: LDAP related
PHP Version: 5.6.20 OS: Ubuntu xenial
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: hcoin at quietfountain dot com
New email:
PHP Version: OS:


 [2016-04-20 13:48 UTC] hcoin at quietfountain dot com
Calls to ldap_connect with present and correct arguments randomly returns 'False'. Same code run again, even in the same debug session, succeeds.

Single stepping with xdebug, examining the variables each step, shows no differences in any variable whether the bind call then fails or works.

When it does fail, the debug log shows:

2016/04/20 07:36:49 [error] 4429#4429: *30 FastCGI sent in stderr: "PHP message: PHP Warning:  ldap_bind(): Unable to bind to server: Can't contact LDAP server in /var/www/fusionpbx/foo.php on line 18
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /var/www/fusionpbx/foo.php:0
PHP message: PHP   2. ldap_bind(*uninitialized*, *uninitialized*, *uninitialized*) /var/www/fusionpbx/foo.php:18" while reading response header from upstream, client:, server: pbx, request: "GET /foo.php?XDEBUG_SESSION_START=netbeans-xdebug HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: ""

Note: the 'ldaps'.  This implementation requires the server to send the caller a valid certificate, but also requires the caller to send the server a valid certificate.
dpkg -l | egrep 'ldap|php|ssl|tls' | grep -vi codec
ii  ldap-utils                         2.4.42+dfsg-2ubuntu3              amd64        OpenLDAP utilities
ii  libcurl3-gnutls:amd64              7.47.0-1ubuntu2                   amd64        easy-to-use client-side URL transfer library (GnuTLS flavour)
ii  libgnutls-deb0-28:amd64            3.3.20-1ubuntu1                   amd64        GNU TLS library - main runtime library
ii  libgnutls-openssl27:amd64          3.4.10-4ubuntu1                   amd64        GNU TLS library - OpenSSL wrapper
ii  libgnutls30:amd64                  3.4.10-4ubuntu1                   amd64        GNU TLS library - main runtime library
ii  libldap-2.4-2:amd64                2.4.42+dfsg-2ubuntu3              amd64        OpenLDAP libraries
ii  libssl1.0.0:amd64                  1.0.2g-1ubuntu4                   amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl1.0.2:amd64              amd64        Secure Sockets Layer toolkit - shared libraries
ii  openssl                        amd64        Secure Sockets Layer toolkit - cryptographic utility
ii  php-cli                            1:7.0+35ubuntu6                   all          command-line interpreter for the PHP scripting language (default)
ii  php-common                         1:35ubuntu6                       all          Common files for PHP packages
ii  php-pear                           1:1.10.1+submodules+notgz-6       all          PEAR Base System
ii  php-xml                            1:7.0+35ubuntu6                   all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php5-cli                  amd64        command-line interpreter for the php5 scripting language
ii  php5-common               amd64        Common files for packages built from the php5 source
ii  php5-curl                 amd64        CURL module for php5
ii  php5-fpm                  amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5-gd                   amd64        GD module for php5
ii  php5-imap                 amd64        IMAP module for php5
ii  php5-json                       amd64        JSON module for php5
ii  php5-ldap                 amd64        LDAP module for php5
ii  php5-mcrypt               amd64        MCrypt module for php5
ii  php5-memcache                      3.0.8-5build1                     amd64        memcache extension module for PHP5
ii  php5-mysql                amd64        MySQL module for php5
ii  php5-odbc                 amd64        ODBC module for php5
ii  php5-readline             amd64        Readline module for php5
ii  php5-sqlite               amd64        SQLite module for php5
ii  php5-xdebug                     amd64        Xdebug Module for PHP 5
rc  php5.6-phpdbg                      5.6.17+dfsg-5                     amd64        server-side, HTML-embedded scripting language (PHPDBG binary)

uname -a
Linux 4.4.0-18-generic #34-Ubuntu SMP Wed Apr 6 14:01:02 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Test script:

$tls_key ="/etc/ldap/certs/pbx.client.rsa.midterm.key.pkcs8.pem";

if (ldap_set_option($c, LDAP_OPT_PROTOCOL_VERSION, 3)) {
    echo "Using LDAPv3\n";
} else {
    echo "Failed to set protocol version to 3\n";
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$d=ldap_bind($c,'cn=Harry Coin,ou=people,dc=foo,dc=com','bar');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-20 19:52 UTC]
-Status: Open +Status: Feedback
 [2018-02-20 19:52 UTC]
Given the intermittent nature, I suspect the underlying system call is being interrupted. Can you try with LDAP_OPT_RESTART, as in:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
ldap_set_option(NULL, LDAP_OPT_RESTART, 1);
// ... as before
 [2018-06-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 01:01:30 2024 UTC