public function connect($ldapUrl)
    {
        // Make sure the connection has been established successfully
        if (! $this->resource = @ldap_connect($ldapUrl)) {
            throw new \Exception(sprintf("Unable to connect to ldap server %s", $ldapUrl));
        }

        // Set sane defaults for ldap v3 protocol
        $this->setOption(LDAP_OPT_PROTOCOL_VERSION, 3)
             ->setOption(LDAP_OPT_REFERRALS, 0);

        return $this;
    }