Frederic Mohr
Committed by GitHub

Update Ldap.php

This is a very crude workaround, a better solution is explained in the comments I added.
...@@ -18,6 +18,24 @@ class Ldap ...@@ -18,6 +18,24 @@ class Ldap
18 */ 18 */
19 public function connect($hostName, $port) 19 public function connect($hostName, $port)
20 { 20 {
21 + /*
22 + * LDAPS is not working because even if port 363 is specified,
23 + * BookStack tries to open a LDAP connection on the LDAPS channel.
24 + * The if-clause below fixed this, although it would be better to
25 + * change the settings in .env from
26 + * LDAP_SERVER=servername:port
27 + * to
28 + * LDAP_SERVER=ldap://servername:389
29 + * LDAP_SERVER=ldaps://servername:363
30 + * in order to be compatible with non-standard setups. Currently,
31 + * specifying ldap:// or ldaps:// results in an error because BookStack
32 + * splits at ":" and takes the seconds chunk (in this case "//servername"
33 + * as the port value.
34 + */
35 + if ($port == 363)
36 + {
37 + $hostName = "ldaps://".$hostName;
38 + }
21 return ldap_connect($hostName, $port); 39 return ldap_connect($hostName, $port);
22 } 40 }
23 41
...@@ -94,4 +112,4 @@ class Ldap ...@@ -94,4 +112,4 @@ class Ldap
94 return ldap_bind($ldapConnection, $bindRdn, $bindPassword); 112 return ldap_bind($ldapConnection, $bindRdn, $bindPassword);
95 } 113 }
96 114
97 -}
...\ No newline at end of file ...\ No newline at end of file
115 +}
......