fixed nasty bug that always set the username to ""

This commit is contained in:
Roland Gruber 2003-03-16 10:25:30 +00:00
parent 6498ab9e2b
commit 5f662c7d6f
1 changed files with 3 additions and 2 deletions

View File

@ -88,15 +88,16 @@ class Ldap{
// $base is optional and specifies the root from where to search for entries // $base is optional and specifies the root from where to search for entries
// if connect succeeds the server handle is returned // if connect succeeds the server handle is returned
function connect($user, $passwd) { function connect($user, $passwd) {
// close any prior connection
@$this->close();
// do not allow anonymous bind // do not allow anonymous bind
if ((!$user)||($user = "")) { if ((!$user)||($user == "")) {
echo _("No username was specified!"); echo _("No username was specified!");
exit; exit;
} }
if ($this->conf->get_SSL() == "True") $this->server = ldap_connect("ldaps://" . $this->conf->get_Host(), $this->conf->get_Port()); if ($this->conf->get_SSL() == "True") $this->server = ldap_connect("ldaps://" . $this->conf->get_Host(), $this->conf->get_Port());
else $this->server = ldap_connect("ldap://" . $this->conf->get_Host(), $this->conf->get_Port()); else $this->server = ldap_connect("ldap://" . $this->conf->get_Host(), $this->conf->get_Port());
if ($this->server) { if ($this->server) {
ldap_set_option($this->server, LDAP_OPT_DEBUG_LEVEL, 0);
$bind = ldap_bind($this->server, $user, $passwd); $bind = ldap_bind($this->server, $user, $passwd);
if ($bind) { if ($bind) {
// return server handle // return server handle