From cadb9efdf9ac268b13e1be5d0481397b811ab671 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 4 Jan 2008 22:38:36 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20on=20v=E9rifie=20si=20le=20user=20existe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/includes/login/functions_ldap.php | 2 +- htdocs/lib/ldap.class.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/includes/login/functions_ldap.php b/htdocs/includes/login/functions_ldap.php index 61898d32494..080b9d4c4cc 100644 --- a/htdocs/includes/login/functions_ldap.php +++ b/htdocs/includes/login/functions_ldap.php @@ -111,7 +111,7 @@ function check_user_password_ldap($usertotest,$passwordtotest) { $resultFetchLdapUser = $ldap->fetch($_POST["username"]); // On stop si le mot de passe ldap doit etre modifie sur le domaine - if ($resultFetchLdapUser == 1 && $ldap->pwdlastset <= 0) + if ($resultFetchLdapUser == 1 && $ldap->pwdlastset == 0) { dolibarr_syslog('functions_ldap::User '.$login.' must change password next logon'); if ($ldapdebug) print "DEBUG: User ".$login." must change password
\n"; diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index f453d793e1b..cb684f38b34 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -872,17 +872,21 @@ class Ldap $i = 0; $searchDN = $this->people; + $result = ''; + while ($i <= 2) { $this->result = @ldap_search($this->connection, $searchDN, $filter); - if (!$this->result) + if ($this->result) + { + $result = @ldap_get_entries( $this->connection, $this->result); + } + else { $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); return -1; - } - - $result = @ldap_get_entries( $this->connection, $this->result); + } if (!$result) { @@ -914,6 +918,7 @@ class Ldap $this->uacf = $this->parseUACF($this->ldap_utf8_decode($result[0]["useraccountcontrol"][0])); $this->pwdlastset = ($result[0]["pwdlastset"][0] != 0)?$this->convert_time($this->ldap_utf8_decode($result[0]["pwdlastset"][0])):0; + if (!$this->name && !$this->login) $this->pwdlastset = -1; $this->badpwdtime = $this->convert_time($this->ldap_utf8_decode($result[0]["badpasswordtime"][0])); ldap_free_result($this->result);