From 2e707edb518c94f2594c9ebd98f0f900c1e670f9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 2 Jun 2007 13:45:54 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20si=20le=20DN=20des=20users=20est=20diff?= =?UTF-8?q?=E9rente=20du=20DN=20de=20l'admin=20on=20cherche=20dans=20le=20?= =?UTF-8?q?domaine=20en=20entier=20afin=20de=20trouver=20l'admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/ldap.class.php | 69 ++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index dae14429ece..3074724be6f 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -883,18 +883,34 @@ class Ldap $this->bindauth($this->searchUser, $this->searchPassword); } - $ldapSearchResult = @ldap_search($this->connection, $this->people, $criteria, $justthese); - - // Si pas de résultat on cherche dans le domaine - if (!$ldapSearchResult) $ldapSearchResult = @ldap_search($this->connection, $this->domain, $criteria, $justthese); - - if (!$ldapSearchResult) + $i = 0; + $searchDN = $this->people; + + while ($i <= 2) { - $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); - return -1; - } + $ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese); + + if (!$ldapSearchResult) + { + $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); + return -1; + } - $entry = ldap_first_entry($this->connection, $ldapSearchResult); + $entry = ldap_first_entry($this->connection, $ldapSearchResult); + + if (!$entry) + { + // Si pas de résultat on cherche dans le domaine + $searchDN = $this->domain; + $i++; + } + else + { + $i++; + $i++; + } + } + if ($entry) { $ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid"); @@ -979,13 +995,34 @@ class Ldap $userIdentifier = $this->getUserIdentifier(); $filter = '('.$this->filter.'('.$userIdentifier.'='.$user.'))'; - - $this->result = @ldap_search($this->connection, $this->people, $filter); - // Si pas de résultat on cherche dans le domaine - if (!$this->result) $this->result = @ldap_search($this->connection, $this->domain, $filter); - - $result = @ldap_get_entries( $this->connection, $this->result); + $i = 0; + $searchDN = $this->people; + + while ($i <= 2) + { + $this->result = @ldap_search($this->connection, $searchDN, $filter); + + if (!$this->result) + { + $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); + return -1; + } + + $result = @ldap_get_entries( $this->connection, $this->result); + + if (!$result) + { + // Si pas de résultat on cherche dans le domaine + $searchDN = $this->domain; + $i++; + } + else + { + $i++; + $i++; + } + } if (! $result) {