active directory - PHP ldap_connect to multiple hosts in case of one beeing not reachable -
a co-worker suggested use multiple hosts website authentication
based on ldap in case 1 host down. know can
$ldap_servers = "10.101.01.1 10.100.10.2"; $ldap = ldap_connect($ldap_servers);
but i'm using config file:
return [ 'domain_controller' => ['10.101.01.1', '10.100.10.2'], 'base_dn' => 'ou=foo,dc=example,dc=local', 'ssl' => false, ... ];
whereas connection done via
$protocol = $this->ssl ? $this::protocol_ssl : $this::protocol; $port = $this->ssl ? $this::port_ssl : $this::port; return $this->connection = ldap_connect($protocol . $hostname, $port);
as co-worker suggested might possible our ldap hosts run via ssl in future, how can make multiple hosts work this? above it's working hostname only, that's because it's non-ssl based. given ssl need ldaps:// protocol , portnumber, right? therefore not work hostname , i'm not sure if can simple connection looks like
ldap_connect('ldaps://' . '10.101.01.1 10.100.10.2', 123);
(supposed both servers run same port ssl based ldap)
edit: got working using ldap_connect('ldaps://hostnameone ldaps://hostnametwo, 636');
reddit user said: "notice still separated spaces, , should tried in order of appearance.."
you should able this:
ldap_connect("ldaps://example.com:389 ldap://example.com:389")
but beware: on starting connection (which not on calling ldap_connect
) try first server , after timeout try next server , on. might cause unwanted delay!
Comments
Post a Comment