Scalr\Net\Ldap\LdapClient::bindRdn PHP Method

bindRdn() protected method

Binds to the LDAP directory with specified RDN and password.
protected bindRdn ( string $username = null, string $password = null ) : boolean
$username string RDN
$password string Password
return boolean Returns TRUE on success or FALSE otherwise
    protected function bindRdn($username = null, $password = null)
    {
        if (!func_num_args()) {
            if ($this->config->user !== null) {
                //Admin user is provided in config.
                $username = $this->config->user;
                $password = $this->config->password;
                if ($this->config->bindType == \Scalr\Net\Ldap\LdapClient::BIND_TYPE_OPENLDAP) {
                    $username = "{$this->config->usernameAttribute}={$username},{$this->config->baseDn}";
                }
            } else {
                //Without admin user we use specified rdn
                $username = $this->username;
                $password = $this->password;
            }
        }
        $res = @ldap_bind($this->conn, (string) $username, (string) $password);
        $this->isbound = $res ? true : false;
        $this->log("Bind username:%s password:%s - %s", $username, str_repeat('*', strlen($password)), $this->isbound ? 'OK' : 'Failed');
        return $res;
    }