Crivaledaz / Mattermost-LDAP

This module provides an external LDAP authentication in Mattermost for the Team Edition (free).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

custom Ldap port

quenenni opened this issue · comments

Describe the bug
A little bug when trying to use a custom port to access the Ldap server.

To Reproduce
Steps to reproduce the behavior:

  1. In 'LDAP/config_ldap.php', put a custom port to $ldap_port (of course, you need to have your Ldap server listening to that port)
  2. Connections to Ldap server are all on port 389

Project (please complete the following information):

  • Project Version: cloned the master few days ago

Additional context

The problem is in LDAP/LDAP.php file, line 40:
$ldap = ldap_connect($ldap_host, $ldap_port)

From https://www.php.net/manual/en/function.ldap-connect.php, the use of the port as a second parameter is deprecated.
They kept it for backwards compatibility, but you have to place the port in the Uri transmitted as the first parameter.

$ldap_uri  = $ldap_host.":".$ldap_port;
$ldap = ldap_connect($ldap_uri)

(careful to not end the ldap_host option with a slash)

And now it connects on the right port.

Could you submit a pull request? This would help ensure a smooth merge into the repository.