public function connect($server, $user = null, $password = null, $isAuthentication = false)
    {
        if ($server && isset($server['host'])) {
            if (isset($server['port']) && is_numeric($server['port'])) {
                $this->connect = ldap_connect($server['host'], $server['port']);
            } else {
                $this->connect = ldap_connect($server['host']);
            }

            ldap_set_option($this->connect, LDAP_OPT_PROTOCOL_VERSION, $server['protocol_version']);

            try {
                if ($isAuthentication && $this->connect && $user && $password) {
                    $user = $this->findDnFromUserName($server, $user);

                    return (false === $user) ? $user : ldap_bind($this->connect, $user, $password);
                } elseif ($this->connect) {
                    return ldap_bind($this->connect);
                }
            } catch (\Exception $e) {
                throw new InvalidLdapCredentialsException();
            }
        }
    }
public function connect($server, $user = null, $password = null, $isAuthentication = false)
    {
        if ($server && isset($server['host'])) {
            if (isset($server['port']) && is_numeric($server['port'])) {
                $this->connect = ldap_connect($server['host'], $server['port']);
            } else {
                $this->connect = ldap_connect($server['host']);
            }

            ldap_set_option($this->connect, LDAP_OPT_PROTOCOL_VERSION, $server['protocol_version']);

            try {
                if ($isAuthentication && $this->connect && $user && $password) {
                    $user = $this->findDnFromUserName($server, $user);

                    return (false === $user) ? $user : ldap_bind($this->connect, $user, $password);
                } elseif ($this->connect) {
                    return ldap_bind($this->connect);
                }
            } catch (\Exception $e) {
                throw new InvalidLdapCredentialsException();
            }
        }
    }
public function connect ( $ server , $ user = null , $ password = null , $ isAuthentication = false ) { if ( $ server && isset ( $ server [ 'host' ] ) ) { if ( isset ( $ server [ 'port' ] ) && is_numeric ( $ server [ 'port' ] ) ) { $ this -> connect = ldap_connect ( $ server [ 'host' ] , $ server [ 'port' ] ) ; } else { $ this -> connect = ldap_connect ( $ server [ 'host' ] ) ; } ldap_set_option ( $ this -> connect , LDAP_OPT_PROTOCOL_VERSION , $ server [ 'protocol_version' ] ) ; try { if ( $ isAuthentication && $ this -> connect && $ user && $ password ) { $ user = $ this -> findDnFromUserName ( $ server , $ user ) ; return ( false === $ user ) ? $ user : ldap_bind ( $ this -> connect , $ user , $ password ) ; } elseif ( $ this -> connect ) { return ldap_bind ( $ this -> connect ) ; } } catch ( \ Exception $ e ) { throw new InvalidLdapCredentialsException ( ) ; } } }
This method create the LDAP link identifier on success and test the connection.

@param server   An array containing LDAP informations as host, port or dn

@return bool
This method create the LDAP link identifier on success and test the connection .