Bug #79637 [Opn->Nab]: ldap_connect ignoring port

From: Date: Wed, 27 May 2020 10:26:43 +0000
Subject: Bug #79637 [Opn->Nab]: ldap_connect ignoring port
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227196@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 Updated by: cmb@php.net Reported by: bugmenot at bfskm dot 33mail dot com Summary: ldap_connect ignoring port -Status: Open +Status: Not a bug Type: Bug Package: LDAP related Operating System: Linux/ANY PHP Version: 7.4.6 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ldap_connect() is "overloaded"; if you call it with two parameters (which is discouraged), the first parameter has to be the hostname (not an URI). Previous Comments: ------------------------------------------------------------------------ [2020-05-26 19:34:10] bugmenot at bfskm dot 33mail dot com ... ------------------------------------------------------------------------ [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

« previous php.bugs (#227196) next »