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();
            }
        }
    }