------------------------------------
Case: Port in protocol address.
Expected result: Connects on port 390.
Actual result: Connects on port 390.
------------------------------------
----
Code
----
<?php
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$cxn = ldap_connect("ldap://somehostname.info:390");
if(!$cxn)
die("couldn't connect");
ldap_set_option($cxn,LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($cxn,LDAP_OPT_REFERRALS,0);
if(!ldap_bind($cxn,NULL,'somepassword'))
die("couldn't bind");
------
Output
------
root@ip-someip:~# php test.php
ldap_create
ldap_url_parse_ext(ldap://somehostname.info:390)
ldap_bind_s
ldap_simple_bind_s
ldap_sasl_bind_s
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP somehostname.info:390
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 192.168.1.101:390
ldap_pvt_connect: fd: 3 tm: -1 async: 0
ldap_open_defconn: successful
ldap_send_server_request
ldap_result ld 0x2ced1c0 msgid 1
wait4msg ld 0x2ced1c0 msgid 1 (infinite timeout)
wait4msg continue ld 0x2ced1c0 msgid 1 all 1
** ld 0x2ced1c0 Connections:
* host: somehostname.info port: 390 (default)
refcnt: 2 status: Connected
last used: Thu Feb 16 16:43:24 2012
** ld 0x2ced1c0 Outstanding Requests:
* msgid 1, origid 1, status InProgress
outstanding referrals 0, parent count 0
ld 0x2ced1c0 request count 1 (abandoned 0)
** ld 0x2ced1c0 Response Queue:
Empty
ld 0x2ced1c0 response count 0
ldap_chkResponseList ld 0x2ced1c0 msgid 1 all 1
ldap_chkResponseList returns ld 0x2ced1c0 NULL
ldap_int_select
read1msg: ld 0x2ced1c0 msgid 1 all 1
read1msg: ld 0x2ced1c0 msgid 1 message type bind
read1msg: ld 0x2ced1c0 0 new referrals
read1msg: mark request completed, ld 0x2ced1c0 msgid 1
request done: ld 0x2ced1c0 msgid 1
res_errno: 0, res_error: <>, res_matched: <>
ldap_free_request (origid 1, msgid 1)
ldap_parse_result
ldap_msgfree
ldap_free_connection 1 1
ldap_send_unbind
ldap_free_connection: actually freed
root@ip-someip:~# vi test.php
root@ip-someip:~# cat test.php
------------------------------------
Case: Port in protocol address.
Expected result: Connects on port 390.
Actual result: Tries to connect on port 389.
------------------------------------
----
Code
----
<?php
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$cxn = ldap_connect("ldap://somehostname.info",390);
if(!$cxn)
die("couldn't connect");
ldap_set_option($cxn,LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($cxn,LDAP_OPT_REFERRALS,0);
if(!ldap_bind($cxn,NULL,'somepassword'))
die("couldn't bind");
------
Output
------
root@ip-someip:~# php test.php
ldap_create
ldap_url_parse_ext(ldap://somehostname.info)
ldap_bind_s
ldap_simple_bind_s
ldap_sasl_bind_s
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP somehostname.info:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 192.168.1.101:389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
ldap_close_socket: 3
ldap_err2string
Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in /root/test.php on line 9
couldn't bind
------------------------------------
System Information
------------------------------------
root@ip-someip:~# uname -a
Linux ip-someip 2.6.32-318-ec2 #38-Ubuntu SMP Thu Sep 1 18:09:30 UTC 2011 x86_64 GNU/Linux
root@ip-someip:~# php -v
PHP 5.3.2-1ubuntu4.9 with Suhosin-Patch (cli) (built: May 3 2011 00:45:52)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH