php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18986 Unable to bind to server
Submitted: 2002-08-20 09:59 UTC Modified: 2002-09-26 19:53 UTC
Votes:15
Avg. Score:3.9 ± 1.2
Reproduced:12 of 13 (92.3%)
Same Version:5 (41.7%)
Same OS:2 (16.7%)
From: luoy at muohio dot edu Assigned:
Status: No Feedback Package: LDAP related
PHP Version: 4.2.2 OS: solaris 6
Private report: No CVE-ID: None
 [2002-08-20 09:59 UTC] luoy at muohio dot edu
compiling and installation was successful. But a single running of LDAP code failed. 

configure options:
./configure  --without-mysql --with-oci8 --with-apxs=/usr/local/apache/bin/apxs --with-ldap=/usr/local --enable-xslt --with-xslt-sablot=/usr/local --with-iconv --with-ssl=/usr/local/ssl --enable-libgcc


LDAP query test
Connecting ...connect result is Resource id #1
Binding ...
Warning: LDAP: Unable to bind to server: Can't contact LDAP server in /home/luoy/public_html/ldap.php on line 12
Bind result is 
...

From LDAP server side, we did not see bind request ( Ususally we can if we use some native tools like ldapseach)

library dependence 
[luoy@admsol03:/home/luoy/src/php-4.1.2]$ldd /usr/local/apache/libexec/libphp4.so 
        libdl.so.1 =>    /usr/lib/libdl.so.1
        libpam.so.1 =>   /usr/dt/lib/libpam.so.1
        libsablot.so.0 =>        /usr/local/lib/libsablot.so.0
        libexpat.so.0 =>         /usr/local/lib/libexpat.so.0
        libsched.so.1 =>         /usr/lib/libsched.so.1
        libsocket.so.1 =>        /usr/lib/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1
        libldap.so.2 =>  /usr/local/lib/libldap.so.2
        liblber.so.2 =>  /usr/local/lib/liblber.so.2
        libresolv.so.2 =>        /usr/lib/libresolv.so.2
        libm.so.1 =>     /usr/lib/libm.so.1
        libclntsh.so.8.0 =>      /opt/oracle/product/817/lib/libclntsh.so.8.0
        libc.so.1 =>     /usr/lib/libc.so.1
        libmp.so.2 =>    /usr/lib/libmp.so.2
        libwtc8.so =>    /opt/oracle/product/817/lib/libwtc8.so
        libaio.so.1 =>   /usr/lib/libaio.so.1
        /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1
 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-20 13:00 UTC] sniper@php.net
Most likely a library clash..as you've got oracle support too, and it has it's own ldap functions. Try pointing --with-ldap to the oracle directory. (/opt/oracle/product/817/)

 [2002-09-05 20:21 UTC] davidkoopman at yahoo dot com
openldap-2.1.4 with this configuration
./configure --prefix=/var/ldap

php-4.2.2 with this configuation:
./configure --with-ldap=/var/ldap

Then upon running this code:
<?php
$basedn = "dc=example,dc=com";
$managerdn = "cn=Manager,$basedn";
$managerpassword = "secret";
echo "Connecting ...\n";
$ds=ldap_connect("localhost");  // must be a valid LDAP server!
echo "connect result is ".$ds."\n\n";
if ($ds) {
    echo "Binding ($managerdn)...";
    $r = ldap_bind($ds, $managerdn, $managerpassword);
    echo "Bind result is ".$r."\n\n";
    ldap_close($ds);
}
?>
I get this error:
LDAP:  Unable to bind to server: Protocol error in /home/dkoopman/ldap_search.php

Here is what the debug mode of my slapd shows:

ldap_pvt_gethostbyname_a: host=devldap.example.net, r=0
connection_get(12): got connid=0
connection_read(12): checking for input on id=0
ber_get_next
ldap_read: want=9, got=9
  0000:  30 31 02 01 01 60 2c 02  01                        01...`,..
ldap_read: want=42, got=42
  0000:  02 04 1c 63 6e 3d 4d 61  6e 61 67 65 72 2c 64 63   ...cn=Manager,dc
  0010:  3d 67 6f 64 61 64 64 79  2c 64 63 3d 63 6f 6d 80   =example,dc=com.
  0020:  09 6c 64 61 70 31 32 33  34 35                     .secret
ber_get_next: tag 0x30 len 49 contents:
ber_get_next
ldap_read: want=9 error=Resource temporarily unavailable
ber_get_next on fd 12 failed errno=11 (Resource temporarily unavailable)
do_bind
ber_scanf fmt ({imt) ber:
ber_scanf fmt (m}) ber:
>>> dnPrettyNormal: <cn=Manager,dc=example,dc=com>
=> ldap_bv2dn(cn=Manager,dc=example,dc=com,0)
<= ldap_bv2dn(cn=Manager,dc=example,dc=com,0)=0
=> ldap_dn2bv(272)
<= ldap_dn2bv(cn=Manager,dc=example,dc=com,272)=0
=> ldap_dn2bv(272)
<= ldap_dn2bv(cn=manager,dc=example,dc=com,272)=0
<<< dnPrettyNormal: <cn=Manager,dc=example,dc=com>, <cn=manager,dc=example,dc=com>
do_bind: version=2 dn="cn=Manager,dc=example,dc=com" method=128
send_ldap_result: conn=0 op=0 p=2
send_ldap_response: msgid=1 tag=97 err=2
ber_flush: 52 bytes to sd 12
  0000:  30 32 02 01 01 61 2d 0a  01 02 04 00 04 26 72 65   02...a-......&re
  0010:  71 75 65 73 74 65 64 20  70 72 6f 74 6f 63 6f 6c   quested protocol
  0020:  20 76 65 72 73 69 6f 6e  20 6e 6f 74 20 61 6c 6c    version not all
  0030:  6f 77 65 64                                        owed
ldap_write: want=52, written=52
  0000:  30 32 02 01 01 61 2d 0a  01 02 04 00 04 26 72 65   02...a-......&re
  0010:  71 75 65 73 74 65 64 20  70 72 6f 74 6f 63 6f 6c   quested protocol
  0020:  20 76 65 72 73 69 6f 6e  20 6e 6f 74 20 61 6c 6c    version not all
  0030:  6f 77 65 64                                        owed


What can be done?  This appears to be a problem with the way PHP is interacting with ldap server.  Notice the "version not allowed" commands in the slapd output.  If I make an entry with the Manager dn using the tools that come with openldap, ldapadd, it shows that it is using version 3.  Looks like PHP is using version 2, which openldap-2.1.4 does not like.  What can be done?  Can somebody create a patch for the ldap.c file?  Help.
 [2002-09-08 17:17 UTC] mose at ns dot cune dot edu
See bug #19281 "OpenLDAP 2.1.4 requires version" for a fix for ldap.c if you are using OpenLDAP 2.1.3 or greater.  (Use at your own risk, of course.)
 [2002-09-09 01:42 UTC] venaas@php.net
I see your reasoning, but I'm opposed to this change. PHP
always defaulted to v2 since the LDAP library did, and if
one used v3 server one had to set the version. To use v3
do as follows before binding:

ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
 [2002-09-26 19:53 UTC] sniper@php.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 "Open". Thank you.


 [2012-11-12 22:33 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328329
Log: Update MySQLi constants.

MYSQLI_TYPE_CHAR is an outdated alias for MYSQL_TYPE_TINY.
The type for CHAR() fields is MYSQLI_TYPE_STRING
see http://dev.mysql.com/doc/refman/5.1/en/c-api-data-structures.html

--
Provided by anonymous #18986 (jg@handcode.de)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 12:01:29 2024 UTC