{"action":"created","issue":{"url":"https://api.github.com/repos/Adldap2/Adldap2/issues/112","labels_url":"https://api.github.com/repos/Adldap2/Adldap2/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/Adldap2/Adldap2/issues/112/comments","events_url":"https://api.github.com/repos/Adldap2/Adldap2/issues/112/events","html_url":"https://github.com/Adldap2/Adldap2/issues/112","id":112846830,"number":112,"title":"Support domain controller failover","user":{"login":"chriseskow","id":19055,"avatar_url":"https://avatars.githubusercontent.com/u/19055?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseskow","html_url":"https://github.com/chriseskow","followers_url":"https://api.github.com/users/chriseskow/followers","following_url":"https://api.github.com/users/chriseskow/following{/other_user}","gists_url":"https://api.github.com/users/chriseskow/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseskow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseskow/subscriptions","organizations_url":"https://api.github.com/users/chriseskow/orgs","repos_url":"https://api.github.com/users/chriseskow/repos","events_url":"https://api.github.com/users/chriseskow/events{/privacy}","received_events_url":"https://api.github.com/users/chriseskow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-22T16:58:41Z","updated_at":"2015-10-22T18:00:38Z","closed_at":null,"body":"PHP's `ldap_connect()` supports a space-separated list of domain controller hosts, and attempts to connect to each successively if it fails to connect to the first one:\r\n\r\n```php\r\n// If corp-dc1.corp.acme.org fails to connect, it will try corp-dc2.corp.acme.org automatically:\r\n$conn = ldap_connect('corp-dc1.corp.acme.org corp-dc2.corp.acme.org');\r\n\r\n// Same, except with SSL:\r\n$conn = ldap_connect('ldaps://corp-dc1.corp.acme.org ldaps://corp-dc2.corp.acme.org');\r\n```\r\n\r\nAdldap does support specifying multiple DCs in its configuration, however it just pick one at random and doesn't attempt to try the others.\r\n\r\nI tried using the space-separated syntax, but that didn't work because Adldap automatically prepends `ldap[s]://` to the hostname:\r\n\r\n```php\r\n// Neither of these workarounds work:\r\n'domain_controllers' => ['corp-dc1.corp.acme.org corp-dc2.corp.acme.org']\r\n'domain_controllers' => ['ldap://corp-dc1.corp.acme.org ldap://corp-dc2.corp.acme.org']\r\n\r\n// This works but is a hack:\r\n'domain_controllers' => ['corp-dc1.corp.acme.org ldap://corp-dc2.corp.acme.org']\r\n```\r\n\r\nCan we either:\r\n\r\n1. Change it so that if you specify multiple DCs, it will concatenate them together (with the correct `ldap[s]://` protocol) when passing to `ldap_connect()`. The downside is I'm not sure if there's a way to have `getDomainControllerSelected()` determine which one it ended up choosing, unless there's some way in the PHP LDAP API.\r\n2. Keep the mulitple-DC behavior as-is and just detect space-separated hostnames and prepend the protocol correctly. This may be confusing to the user though because then there'd be two ways of specifying multiple DCs, one with failover support and the other without.\r\n3. Change the connect behavior to catch connection errors and try each DC in turn. Basically, re-implement `ldap_connect()`'s failover behavior in PHP.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/Adldap2/Adldap2/issues/comments/150306975","html_url":"https://github.com/Adldap2/Adldap2/issues/112#issuecomment-150306975","issue_url":"https://api.github.com/repos/Adldap2/Adldap2/issues/112","id":150306975,"user":{"login":"stevebauman","id":6421846,"avatar_url":"https://avatars.githubusercontent.com/u/6421846?v=3","gravatar_id":"","url":"https://api.github.com/users/stevebauman","html_url":"https://github.com/stevebauman","followers_url":"https://api.github.com/users/stevebauman/followers","following_url":"https://api.github.com/users/stevebauman/following{/other_user}","gists_url":"https://api.github.com/users/stevebauman/gists{/gist_id}","starred_url":"https://api.github.com/users/stevebauman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevebauman/subscriptions","organizations_url":"https://api.github.com/users/stevebauman/orgs","repos_url":"https://api.github.com/users/stevebauman/repos","events_url":"https://api.github.com/users/stevebauman/events{/privacy}","received_events_url":"https://api.github.com/users/stevebauman/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T18:00:38Z","updated_at":"2015-10-22T18:00:38Z","body":"You're right about this as well, this needs to be implemented. I wasn't aware of this functionality in the `ldap_connect()` method.\r\n\r\nI'll keep the array of domain controllers as is, and append each of the controllers into the `ldap_connect()` method with the appropriate protocol prefix. I'll comment back when I have some commits, and let me know what you think, thanks!"}}