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