<?php

namespace Buckhill\LDAP;

use Buckhill\LDAP\Errors\ConnectionError;
use Buckhill\LDAP\Errors\NoConnectionError;

/**
 * Interface ClientInterface
 * @package Buckhill\LDAP
 */
interface ClientInterface
{
    public function __construct($host, $port, array $options = null, $tls = false);


    /**
     * @return bool
     * @throws ConnectionError
     */
    public function connect();


    /**
     * @return bool
     */
    public function isConnected();


    /**
     * @return void
     * @throws NoConnectionError
     */
    public function checkIfConnected();


    /**
     * Alias of bind, but it doesn't support anonymous bind (difference is in the 3rd parameter)
     *
     * @param $username
     * @param $password
     *
     * @return bool
     */
    public function authenticate($username, $password);


    /**
     * @return bool
     */
    public function anonymous();


    /**
     * @param null       $username
     * @param null       $password
     * @param bool|false $anonymous
     *
     * @return bool
     */
    public function bind($username = null, $password = null, $anonymous = false);


    /**
     * @param       $dn
     * @param array $entry
     *
     * @return bool
     */
    public function modify($dn, array $entry);


    /**
     * Turns a string into another string that can be used to modify user's password in the directory
     *
     * @return string
     */
    public function toPassword($password);


    /**
     * @return int
     */
    public function errorNumber();


    /**
     * @return string
     */
    public function errorString();
}