/** * Connects and Binds to the Domain Controller. * * @return bool * * @throws AdldapException */ public function connect() { // Select a random domain controller $domainController = $this->domainControllers[array_rand($this->domainControllers)]; // Get the LDAP port $port = $this->getPort(); // Create the LDAP connection $this->ldapConnection->connect($domainController, $port); // Set the LDAP options $this->ldapConnection->setOption(LDAP_OPT_PROTOCOL_VERSION, 3); $this->ldapConnection->setOption(LDAP_OPT_REFERRALS, $this->followReferrals); // Authenticate to the server return $this->authenticate($this->getAdminUsername(), $this->getAdminPassword(), true); }