Adldap\Connections\Ldap::connect PHP Method

connect() public method

public connect ( $hosts = [], $port = '389' )
    public function connect($hosts = [], $port = '389')
    {
        $connections = $this->getConnectionString($hosts, $this->getProtocol(), $port);
        return $this->connection = ldap_connect($connections);
    }

Usage Example

Example #1
0
 /**
  * This tests that an exception is thrown
  * when trying to perform an LDAP method while
  * showing errors.
  */
 public function testConnectionShowErrors()
 {
     $ldap = new Ldap();
     $ldap->showErrors();
     $ldap->connect('test');
     try {
         $ldap->bind('test', 'test');
         $passes = false;
     } catch (\Exception $e) {
         $passes = true;
     }
     $this->assertTrue($passes);
 }