Bug #79637 [Opn]: ldap_connect ignoring port

From: Date: Tue, 26 May 2020 19:34:10 +0000
Subject: Bug #79637 [Opn]: ldap_connect ignoring port
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227187@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79637&edit=1

 ID:                 79637
 User updated by:    bugmenot at bfskm dot 33mail dot com
 Reported by:        bugmenot at bfskm dot 33mail dot com
 Summary:            ldap_connect ignoring port
 Status:             Open
 Type:               Bug
-Package:            *Network Functions
+Package:            LDAP related
 Operating System:   Linux/ANY
 PHP Version:        7.4.6
 Block user comment: N
 Private report:     N

 New Comment:

...


Previous Comments:
------------------------------------------------------------------------
[2020-05-26 19:30:28] bugmenot at bfskm dot 33mail dot com

Description:
------------
It turned out that the ldap port argument from ldap_connect($URI,intval(1234)
) was ignored , and the port set in URI made it possible 

( more info here : https://github.com/glpi-project/glpi/issues/7316
)

Test script:
---------------
<?php
//there is a server with ssl on port 6366
// SETTING PORT IN LDAP URL 
$ldaphost = "ldaps://brother.hood.local:6636";
$ldapUsername  = "uid=realuser,cn=Users,dc=hood,dc=local";
$ldapPassword = "ARealUsersPassword";
$ldapUsername  = "cn=inventory_hq_hood_systems,cn=computers,dc=hood,dc=local";
$ldapPassword = "IB3t0nlyGøD_Y0urMøm_AndBillGatesNowMyPassWordIs_TotallyInsecure";

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
//FAILS:
//$ds = ldap_connect($ldaphost,intval(6366));
//WORKS
$ds = ldap_connect($ldaphost);
if (!$ds) { echo "No Connection";}


if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
print "Could not set LDAPv3\r\n";
}
else {
   ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
//  if (!@ldap_start_tls($ds)) {echo "No Starttls";}

// now we need to bind to the ldap server
$bth = ldap_bind($ds, $ldapUsername, $ldapPassword) or die("\r\nCould not connect to LDAP
server\r\n");
}

?>

Expected result:
----------------
connect to the port given on second argument

Actual result:
--------------
connects to default port 389


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



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


Thread (3 messages)

« previous php.bugs (#227187) next »