Mandi! baaZ
  In chel di` si favelave...

> For me that's seems ok.

Ok, i've reworked a bit all the things, and now i can attach a more
clean patch.
Last patch was an hack, this no, so probably i've broke something...
;)))

This patch do:

+ add a costructor to User class that build a minimal set of user data
  in fields() array.
+ add a parameter $name for construction Identification(), same reason
+ Identification->connection_imap(): moved internally the check for $host
  defined, converted to boolean
+ added Identification->connection_ldap()
+ renamed Identification->connection_db_mysql() to connection_db(),
  converted to boolean, fail if password empty, does not load user data
  from DB (check only the password).
+ removed Identification->add_an_user()
+ removed the check for the password from checkAuthentication(), it is
  needed? I've removed because broke something, but the doubt remains...
+ removed $cfg_login['use_extern'] from config file, if you sed ldap or
  imap hosts, they are used.
+ added User->getFromLDAP()
+ added User->getFromIMAP()
+ hard rewrite of login.php


> I've to find a way to reduce the time of an imap login failure, because 
> it takes really too much time, don't know how it is for LDAP.

No, LDAP is very quick. For imap... there's no way to speed it up,
AFAIK.


> I try too have a look at the patch tomorrow, I wonder if we've to 
> include it to the 0.3 or not...

As stated, i'm not using glpi for now, so for me there's no absolutely
differences...

-- 
dott. Marco Gaiarin                                 GNUPG Key ID: 240A3D66
  Associazione ``La Nostra Famiglia''                http://www.sv.lnf.it/
  Polo FVG  -  Via della Bontà, 7 - 33078  -  San Vito al Tagliamento (PN)
  gaio(at)sv.lnf.it             tel +39-0434-842711    fax +39-0434-842797

    ... votantoniovotantoniovotantoniovotantoniovotantoniovotantonio ...
             resistenza arcobaleno contro la politica grigia

                    http://www.peacelink.it/votantonio
diff -udrN -x Entries cvs/glpi/common/classes.php dev/glpi/common/classes.php
--- cvs/glpi/common/classes.php 2004-05-06 18:15:08.000000000 +0200
+++ dev/glpi/common/classes.php 2004-05-28 15:10:19.000000000 +0200
@@ -157,11 +157,11 @@
        var $user;
 
        //constructor for class Identification
-       function Identification()
+       function Identification($name)
        {
                //echo "il est passé par ici";
                $this->err = "";
-               $this->user = new User;
+               $this->user = new User($name);
        }
 
 
@@ -170,21 +170,59 @@
        //else return 0
        function connection_imap($host,$login,$pass)
        {
+               // we prevent some delay...
+               if (empty($host)) {
+                       return false;
+               }
+
                error_reporting(16);
                if($mbox = imap_open($host,$login,$pass))
                //if($mbox)$mbox =
                {
                        imap_close($mbox);
-                       return 1;
-               }
-               else
-               {
-                       $this->err = imap_last_error();
-                       imap_close($mbox);
-                       return 0;
+                       return true;
                }
+
+               $this->err = imap_last_error();
+               imap_close($mbox);
+               return false;
        }
 
+  // return 1 if the connection to the LDAP host, auth mode, was successful
+  //
+  function connection_ldap($host,$basedn,$login,$pass)
+  {
+               // we prevent some delay...
+               if (empty($host)) {
+                       return false;
+               }
+
+       error_reporting(16);
+       $dn = "uid=" . $login . "," . $basedn;
+       $rv = false;
+       
+       if ( $conn = ldap_connect($host) )
+       {
+               // switch to protocol version 3 to make ssl work
+               ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3) ;
+               if ( ldap_bind($conn, $dn, $pass) ) {
+                       $rv = true;
+               }
+               else
+               {
+                       $this->err = ldap_error();
+               }
+               ldap_close($conn);
+       }
+       else
+       {
+               $this->err = ldap_error();
+       }
+       
+       return($rv);
+
+  } // connection_ldap()
+               
 
        // void;
        //try to connect to DB
@@ -192,33 +230,40 @@
        //and the password is $password in the DB.
        //If not found or can't connect to DB updates the instance variable err
        //with an eventual error message
-       function connection_db_mysql($name,$password)
+       function connection_db($name,$password)
        {
+
+               // sanity check... we prevent empty passwords...
+               //
+               if ( empty($password) )
+               {
+                       $this->err = "Empty Password";
+                       return false;
+               }
+               
                $db = new DB;
                $query = "SELECT * from users where (name = '".$name."' && 
password = PASSWORD('".$password."'))";
                $result = $db->query($query);
                //echo $query;
                if($result)
                {
-                       if($db->numrows($result))
+                       if($db->numrows($result) == 1)
                        {
-                               $this->user->getFromDB($name);
-                               return 2;
+                               return true;
                        }
                        else
                        {
                                $this->err = "Bad username or password";
-                               return 1;
+                               return false;
                        }
                }
-               else
-               {
-                       $err = "Erreur numero : ".$db->errno().": ";
-                       $err += $db->error();
-                       return 0;
-               }
 
-       }
+               $this->err = "Erreur numero : ".$db->errno().": ";
+               $this->err += $db->error();
+               return false;
+
+       } // connection_db()
+
 
        // Set Cookie for this user
        function setCookies()
@@ -231,7 +276,7 @@
                $_SESSION["glpiname"] = $name;
                $_SESSION["glpitype"] = $type;
                $_SESSION["authorisation"] = true;
-               //SetCookie("IRMName", $name, 0, "/");
+               SetCookie("IRMName", $name, 0, "/");
                //SetCookie("IRMPass", $password, 0, "/");
        }
 
@@ -243,43 +288,6 @@
        $_SESSION["authorisation"] = false;
        }
 
-       //Add an user to DB or update his password if user allready exist.
-       //The default type of the added user will be 'post-only'
-       function add_an_user($name, $password, $host)
-       {
-
-               // Update user password if already known
-               if ($this->connection_db_mysql($name,$password) == 2)
-               {
-                       $update[0]="password";
-                       $this->user->fields["password"]=$password;
-                       $this->user->updateInDB($update);
-
-               }// Add user if not known
-               else
-               {
-                       // dump status
-
-                       $this->user->fields["name"]=$name;
-                       if(empty($host))
-                       {
-                       $this->user->fields["email"]=$name;
-                       }
-                       else
-                       {
-                       $this->user->fields["email"]=$name."@".$host;
-                       }
-                       $this->user->fields["type"]="post-only";
-                       $this->user->fields["realname"]=$name;
-                       $this->user->fields["can_assign_job"]="no";
-                       $this->user->addToDB();
-                       $update[0]="password";
-                       $this->user->fields["password"]=$password;
-               $this->user->updateInDB($update);
-               }
-
-       }
-
        function getErr()
        {
                return $this->err;
diff -udrN -x Entries cvs/glpi/common/functions.php 
dev/glpi/common/functions.php
--- cvs/glpi/common/functions.php       2004-05-26 16:14:47.000000000 +0200
+++ dev/glpi/common/functions.php       2004-05-28 15:57:12.000000000 +0200
@@ -87,12 +87,12 @@
                echo "<b><a 
href=\"".$cfg_install["root"]."/logout.php\">".$lang["login"][1]."</a></b></center>";
                nullFooter();
                exit();
-       } else if ($_SESSION["glpipass"] != md5($password)) {
+/*     } else if ($_SESSION["glpipass"] != md5($password)) {
                nullHeader($lang["login"][4],$_SERVER["PHP_SELF"]);
                echo "<center><b>".$lang["login"][2]."</b><br><br>";
                echo "<b><a 
href=\"".$cfg_install["root"]."/logout.php\">".$lang["login"][1]."</a></b></center>";
                nullFooter();
-               exit();
+               exit(); */
        } else {
                header("Vary: User-Agent");
 
diff -udrN -x Entries cvs/glpi/config/config.php dev/glpi/config/config.php
--- cvs/glpi/config/config.php  2004-05-26 16:14:48.000000000 +0200
+++ dev/glpi/config/config.php  2004-05-28 15:58:37.000000000 +0200
@@ -49,16 +49,16 @@
 // Configuration standard changez selon vos besoins.
 class DB extends DBmysql {
 
-       var $dbhost     = "localhost";
-       var $dbuser     = "root"; 
+       var $dbhost     = "mysql";
+       var $dbuser     = "gaio"; 
        var $dbpassword = "";
-       var $dbdefault  = "glpidb";
+       var $dbdefault  = "glpisv";
 }
 
 
 //root document
 //document root
-$cfg_install["root"]           = "/glpi-gna";
+$cfg_install["root"]           = "/~gaio/glpi";
 
 
 // *************************** Eléments optionnels  **********************
@@ -88,13 +88,6 @@
                                
 }
 
-//put $cfg_login['use_extern'] = 1 if you want to use external sources for 
login
-//default set to 0
-//mettez cette option a 1 si vous vous voulez utiliser des sources
-//d'informations externes/alternatives pour le login
-//par defaut laissez cette valeur a 0;
-$cfg_login['use_extern'] = 0;
-
 // Gestion de source d'information alternatives pour le login
 // telles que des serveurs de mail en imap pop...
 // ports standards : pop 110 , imap 993
@@ -105,8 +98,20 @@
 // Si plusieurs sources alternatives sont définies, seule la première
 // fournissant un login correct est utilisé
 
-$cfg_login['imap']['auth_server'] = "{localhost:993/imap/ssl/novalidate-cert}";
-$cfg_login['imap']['host'] = "sic.sp2mi.xxxx.fr";
+$cfg_login['imap']['auth_server'] = "{mail.sv.lnf.it:143}INBOX";
+$cfg_login['imap']['host'] = "sv.lnf.it";
+
+// LDAP setup.
+// We can use LDAP both for authentication and for user information
+$cfg_login['ldap']['host'] = "ldap://ldap.sv.lnf.it";;
+$cfg_login['ldap']['basedn'] = "ou=People,dc=sv,dc=lnf,dc=it";
+// some lDAP server (eg, M$ Active Directory) does not like anonymous
+// bind
+//$cfg_login['ldap']['user'] = "cn=admin,ou=People,dc=sv,dc=lnf,dc=it";
+//$cfg_login['ldap']['pass'] = "secret";
+// relation between the GLPI users table field and the LDAP field
+$cfg_login['ldap']['fields'] = array( "name" => "uid", "email" => "mail", 
"location" => "physicaldeliveryofficename", "phone" => "telephonenumber", 
"realname" => "cn");
+
 
 //other sources
 //$cfg_login['other_source']...
@@ -215,7 +220,7 @@
 
  // dicts
 //dictionnaires
-$cfg_install["languages"]      = array("english","deutsch","french");
+$cfg_install["languages"]      = array("english","deutsch","french","italian");
 
 // END OF CONFIGURATION
 
diff -udrN -x Entries cvs/glpi/config/.#config.php.1.5 
dev/glpi/config/.#config.php.1.5
--- cvs/glpi/config/.#config.php.1.5    1970-01-01 01:00:00.000000000 +0100
+++ dev/glpi/config/.#config.php.1.5    2004-05-06 18:24:47.000000000 +0200
@@ -0,0 +1,244 @@
+<?php
+/*
+
+ ----------------------------------------------------------------------
+GLPI - Gestionnaire libre de parc informatique
+ Copyright (C) 2002 by the INDEPNET Development Team.
+ http://indepnet.net/   http://glpi.indepnet.org
+ ----------------------------------------------------------------------
+ Based on:
+IRMA, Information Resource-Management and Administration
+Christian Bauer, [EMAIL PROTECTED]
+
+ ----------------------------------------------------------------------
+ LICENSE
+
+This file is part of GLPI.
+
+    GLPI is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    GLPI is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with GLPI; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ ----------------------------------------------------------------------
+ Original Author of file:
+ Purpose of file:
+ ----------------------------------------------------------------------
+*/
+ //And Julien Dombre for externals identifications
+ 
+
+//Toutes les options notifiées "non supportées par glpi v0.2 sont liées
+// au fonctions LDAP et mail (Qmail) présentes dans IRMA
+// GLPI  CONFIGURATION OPTIONS
+
+
+// *************************** Eléments à renseigner impérativement ********
+// *************************************************************************
+// *************************************************************************
+
+// Basic MYSQL configuration change as you need/want.
+// Configuration standard changez selon vos besoins.
+class DB extends DBmysql {
+
+       var $dbhost     = "mysql";
+       var $dbuser     = "gaio"; 
+       var $dbpassword = "";
+       var $dbdefault  = "glpisv";
+}
+
+
+//root document
+//document root
+$cfg_install["root"]           = "/~gaio/glpi";
+
+
+// *************************** Eléments optionnels  **********************
+// ***********************************************************************
+// ***********************************************************************
+
+// Navigation Functions
+// Fonctions du menu
+class baseFunctions {
+       // Could have inventory, maintain, admin and settings, 
+       //changes these values on the dicts on header menu.
+
+       
+       var $inventory  = true;
+
+       var $maintain   = true;
+
+// set $admin to "false" to disable the LDAP-Browser
+// Laisser $admin = false si vous n'utilisez pas le navigateur LDAP
+// Le navigateur LDAP n'as pas été touché par les developpeurs de GLPI,
+// il s'agit donc de la version basée sur IRMA.
+// Il est conseillé de laisser false.
+       var $admin      = false;
+
+       var $settings   = true;
+
+                               
+}
+
+//put $cfg_login['use_extern'] = 1 if you want to use external sources for 
login
+//default set to 0
+//mettez cette option a 1 si vous vous voulez utiliser des sources
+//d'informations externes/alternatives pour le login
+//par defaut laissez cette valeur a 0;
+$cfg_login['use_extern'] = 0;
+
+// Gestion de source d'information alternatives pour le login
+// telles que des serveurs de mail en imap pop...
+// ports standards : pop 110 , imap 993
+// Dans tous les cas le dernier type de login testé est la base de données
+// Dans le cas où le login est incorrect dans la base mais est correct
+// sur la source alternative, l'utilisateur est ajouté ou son mot de passe
+// est modifié
+// Si plusieurs sources alternatives sont définies, seule la première
+// fournissant un login correct est utilisé
+
+$cfg_login['imap']['auth_server'] = "{localhost:993/imap/ssl/novalidate-cert}";
+$cfg_login['imap']['host'] = "sic.sp2mi.xxxx.fr";
+
+//other sources
+//$cfg_login['other_source']...
+
+// Features configuration
+
+// Log level :
+// Niveau de log :
+
+// 1 - Critical (login failures) |  (erreur de loging seulement)
+// 2 - Severe - not used  | (non utilisé)
+// 3 - Important - (sucessfull logins)  |  importants (loging réussis)
+// 4 - Notice (updates, adds, deletes, tracking) | classique
+// 5 - Junk (i.e., setup dropdown fields, update users or templates) | log 
tout (ou presque)
+$cfg_features["event_loglevel"]        = 5;
+
+// Utilisation des fonctions mailing ou non
+$cfg_features["mailing"]       = 0;    
+// Addresse de l'administrateur (obligatoire si mailing activé)
+$cfg_mailing["admin_email"]    = "[EMAIL PROTECTED]";  
+// Signature for automatic generated E-Mails
+$cfg_mailing["signature"]      = "SIGNATURE";
+
+// Définition des envois des mails d'informations
+// admin : vers le mail $cfg_features["admin_email"]
+// all_admin : tous les utilisateurs en mode admin
+// all_normal : toutes les utilisateurs en mode normal
+// attrib : personne responsable de la tache
+// user : utilisateur demandeur
+// 1 pour l'envoi et 0 dans el cas contraire 
+
+$cfg_mailing["new"]["admin"]=1;
+$cfg_mailing["attrib"]["admin"]=1;
+$cfg_mailing["followup"]["admin"]=1;
+$cfg_mailing["finish"]["admin"]=1;
+
+$cfg_mailing["new"]["all_admin"]=0;
+$cfg_mailing["attrib"]["all_admin"]=0;
+$cfg_mailing["followup"]["all_admin"]=0;
+$cfg_mailing["finish"]["all_admin"]=0;
+
+
+$cfg_mailing["new"]["all_normal"]=0;
+$cfg_mailing["attrib"]["all_normal"]=0;
+$cfg_mailing["followup"]["all_normal"]=0;
+$cfg_mailing["finish"]["all_normal"]=0;
+
+$cfg_mailing["attrib"]["attrib"]=1;
+$cfg_mailing["followup"]["attrib"]=1;
+$cfg_mailing["finish"]["attrib"]=1;
+
+$cfg_mailing["new"]["user"]=1;
+$cfg_mailing["attrib"]["user"]=1;
+$cfg_mailing["followup"]["user"]=1;
+$cfg_mailing["finish"]["user"]=1;
+
+
+
+// Show jobs at login.
+// Montrer les interventions au loging (1 = oui | 0 = non)
+$cfg_features["jobs_at_login"] = 1;
+
+// Show last num_of_events on login.
+// Nombre des derniers evenements presents dans le tableau au loging
+$cfg_features["num_of_events"] = 10;
+
+// Send Expire Headers and set Meta-Tags for proper content expiration.
+$cfg_features["sendexpire"]            = 1;
+
+// In listings, cut long text fields after cut characters.
+$cfg_features["cut"]                   = 80;   
+
+// Expire events older than this days at every login
+// (only admin-level login, set to 0 to disable expiration).
+// Temps durant lequel on log les actions ayant eu lieu
+// mettez cette variable a 0 pour conserver tous les logs (prend beaucoup de 
place dans la bdd)
+$cfg_features["expire_events"] = 30;
+
+// Threshold for long listings, activates pager.
+//Nombre d'occurence (ordinateurs, imprimantes etc etc...) qui apparaitrons 
dans
+//la liste de recherche par page.
+$cfg_features["list_limit"]            = 15;   
+                                                                       
+
+// Report generation
+// Default Report included
+$report_list["default"]["name"] = "Rapport par défaut";
+$report_list["default"]["file"] = "reports/default.php";
+
+// Vous pouvez faire vos propres rapports :
+// My Own Report:
+// $report_list["my_own"]["name"] = "My Own Report";
+// $report_list["my_own"]["file"] = "reports/my_own.php";
+
+
+// Rapport ajoutés par GLPI V0.2
+$report_list["Maintenance"]["name"] = "Maintenance";
+$report_list["Maintenance"]["file"] = "reports/maintenance.php";
+$report_list["Par_annee"]["name"] = "Par date";
+$report_list["Par_annee"]["file"] = "reports/parAnnee.php";
+$report_list["excel"]["name"] = "excel";
+$report_list["excel"]["file"] = "reports/geneExcel.php";
+
+// options d'installation et interface graphique
+// Installation and graphical options
+
+// version number
+// numero de version
+$cfg_install["version"]                =" 0.3 Alpha ";
+  
+
+// dicts
+//dictionnaires
+$cfg_install["languages"]      = array("english","deutsch","french");
+
+//logo
+$cfg_layout["logogfx"]         = "/glpi/pics/logo-glpi.png";
+//txt du logo
+$cfg_layout["logotxt"]         = "GLPI powered by indepnet";
+
+
+// Interface graphique...
+
+$cfg_layout["body_bg"]         = "#FFFFFF";
+$cfg_layout["body_text"]       = "#000000";
+$cfg_layout["body_link"]       = "#009966";
+$cfg_layout["body_vlink"]      = "#009966";
+$cfg_layout["body_alink"]      = "#009966";
+
+$cfg_layout["tab_bg_1"]        = "#cccccc";
+$cfg_layout["tab_bg_2"]                = "#dddddd";
+$cfg_layout["tab_bg_3"]                = "#eeeeee";
+
+// END OF CONFIGURATION
+?>
diff -udrN -x Entries cvs/glpi/dicts/italian.php dev/glpi/dicts/italian.php
--- cvs/glpi/dicts/italian.php  1970-01-01 01:00:00.000000000 +0100
+++ dev/glpi/dicts/italian.php  2004-05-27 18:06:06.000000000 +0200
@@ -0,0 +1,524 @@
+<?php
+/*
+ 
+ ----------------------------------------------------------------------
+GLPI - Gestionnaire libre de parc informatique
+ Copyright (C) 2002 by the INDEPNET Development Team.
+ http://indepnet.net/   http://glpi.indepnet.org
+ ----------------------------------------------------------------------
+ Based on:
+IRMA, Information Resource-Management and Administration
+Christian Bauer, [EMAIL PROTECTED] 
+
+ ----------------------------------------------------------------------
+ LICENSE
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License (GPL)
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ To read the license please visit http://www.gnu.org/copyleft/gpl.html
+ ----------------------------------------------------------------------
+ Original Author of file:
+ Purpose of file:
+ Translator: Marco Gaiarin  < gaio (at) sv . lnf . it >
+ ----------------------------------------------------------------------
+*/
+
+
+
+// English Dictionary
+
+//Login
+
+$lang["login"][0] = "Impossibile effettuare il login, verifica che il tuo 
browser sia configurato per accettare i cookie";
+$lang["login"][1] = "Riprova il login";
+$lang["login"][2] = "La password non &eacute; più valida: se l'hai appena 
cambiata, ti prego utilizza la nuova password";
+$lang["login"][3] = "Login non effettuato";
+$lang["login"][4] = "Password non corretta";
+$lang["login"][5] = "Accesso non consentito";
+
+
+// Global
+$lang["buttons"][0]    = "Cerca";
+$lang["buttons"][1]    = "Elenca";
+$lang["buttons"][2]    = "Invia";
+$lang["buttons"][3]    = "Assegna";
+$lang["buttons"][4]    = "Installa";
+$lang["buttons"][5]    = "Deinstalla";
+$lang["buttons"][6]    = "Cancella";
+$lang["buttons"][7]    = "Aggiorna";
+$lang["buttons"][8]    = "Aggiungi";
+$lang["buttons"][9]    = "Connetti";
+$lang["buttons"][10]   = "Disconnetti";
+$lang["buttons"][11]   = "Prossimo";
+$lang["buttons"][12]   = "Precedente";
+$lang["buttons"][13]   = "Indietro";
+$lang["buttons"][14]   = "Cambia";
+$lang["buttons"][15]    = "Calendario";
+
+$lang["choice"][0]     = "No";
+$lang["choice"][1]     = "S&iacute;";
+
+$lang["search"][0]     = "Cerca per";
+$lang["search"][1]     = "dove questo campo";
+$lang["search"][2]     = "contiene";
+$lang["search"][3]     = "&eacute; l'esatta frase";
+$lang["search"][4]     = "ordinato per";
+$lang["search"][5]     = "Visualizza per posizione";
+$lang["search"][6]     = "ordinato per";
+
+// Central
+$lang["central"][0]    = "Benvenuto ";
+$lang["central"][1]    = "questa &eacute; la console centrale.";
+$lang["central"][2]    = "Ultimo/i";
+$lang["central"][3]    = "Evento/i";
+$lang["central"][4]    = "Nessun Evento.";
+$lang["central"][5]    = "Home";
+$lang["central"][6]    = "Uscita";
+//repports
+
+
+$lang["event"][0]      = "Item (ID)";
+$lang["event"][1]      = "Data";
+$lang["event"][2]      = "Servizio";
+$lang["event"][3]      = "Livello";
+$lang["event"][4]      = "Messaggio";
+
+// Pager
+$lang["pager"][1]      = "a";
+$lang["pager"][2]      = "da";
+
+// Direct Connections
+$lang["connect"][0]    = "Connessioni dirette";
+$lang["connect"][1]    = "non connesso...";
+$lang["connect"][2]    = "Connetti";
+$lang["connect"][3]    = "Disconnetti";
+$lang["connect"][4]    = "Crea una connessione diretta";
+$lang["connect"][5]    = "a un computer che";
+$lang["connect"][6]    = "Nome";
+$lang["connect"][7]    = "ID";
+$lang["connect"][8]    = "contiene";
+$lang["connect"][9]    = "Prego, scegli un computer dalla lista";
+
+//header menu
+$lang["Menu"][0]       ="Computer";
+$lang["Menu"][1]       ="Apparecchiature di rete";
+$lang["Menu"][2]       ="Stampanti";
+$lang["Menu"][3]       ="Monitor";
+$lang["Menu"][4]       ="Software";
+$lang["Menu"][5]       ="Richieste";
+$lang["Menu"][6]       ="Statistiche";
+$lang["Menu"][7]       ="Gruppi";
+$lang["Menu"][8]       ="Account";
+$lang["Menu"][9]       ="Account di posta";
+$lang["Menu"][10]      ="Setup";
+$lang["Menu"][11]      ="Preferenze";
+$lang["Menu"][12]      ="Dati";
+
+//Data
+
+$lang["backup"][0]         ="Dump SQL";
+$lang["backup"][1]      ="Dump XML";
+$lang["backup"][2]      ="Crea un backup del database";
+$lang["backup"][3]      ="Il file è stato creato";
+$lang["backup"][5]      ="Apri il file";
+$lang["backup"][6]      ="Struttura della tabella";
+$lang["backup"][7]      ="Dati della tabella";
+$lang["backup"][8]      ="ripristinati con successo!";
+$lang["backup"][9]      ="cancellati con successo!";
+$lang["backup"][10]     ="File";
+$lang["backup"][11]     ="Dimensione";
+$lang["backup"][12]     ="Data";
+$lang["backup"][13]     ="Visualizza/Download";
+$lang["backup"][14]     ="Ripristinato";
+$lang["backup"][15]     ="Sei sicuro di voler salvare il database";
+$lang["backup"][16]     ="Sei sicuro di voler sovrascrivere il database con il 
file";
+$lang["backup"][17]     ="Sei sicuro di voler eliminare questo file";
+$lang["backup"][18]     ="Sei sicuro di voler salvare il database";
+$lang["backup"][19]     ="adess";
+$lang["backup"][20]     ="Elimina";
+// Tracking
+$lang["tracking"][0]   = "Follow up of interventions";
+$lang["tracking"][1]   = "Show all active interventions";
+$lang["tracking"][2]   = "Show only intervention assigned to you";
+$lang["tracking"][3]   = "Show only interventions not assigned yet";
+$lang["tracking"][4]   = "Show only old interventions";
+$lang["tracking"][5]   = "Where the description contains";
+$lang["tracking"][6]    = "You are not allowed to (re-)assign this 
intervention";
+
+$lang["joblist"][0]    = "Stato";
+$lang["joblist"][1]    = "Data";
+$lang["joblist"][2]    = "Priorit&agrave;";
+$lang["joblist"][3]    = "Autore";
+$lang["joblist"][4]    = "Assegnatario";
+$lang["joblist"][5]    = "Computer";
+$lang["joblist"][6]    = "Descrizione";
+$lang["joblist"][7]    = "Nuovo lavoro per questo elemento...";
+$lang["joblist"][8]    = "Nessun lavoro trovato.";
+$lang["joblist"][9]    = "NUOVO";
+$lang["joblist"][10]   = "VECCHIO";
+$lang["joblist"][11]   = "Aperto il";
+$lang["joblist"][12]   = "Chiuso il";
+$lang["joblist"][13]   = "Maggiori informazioni";
+$lang["joblist"][14]   = "Chiudi";
+$lang["joblist"][15]   = "Assegna";
+$lang["joblist"][16]   = "Nessun intervento in corso.";
+$lang["joblist"][17]   = "Molto Alta";
+$lang["joblist"][18]   = "Alta";
+$lang["joblist"][19]   = "Normale";
+$lang["joblist"][20]   = "Bassa";
+$lang["joblist"][21]   = "Molto Bassa";
+$lang["job"][0]                = "Numero di intervento";
+$lang["job"][1]                = "Intervento ancora aperto...";
+$lang["job"][2]                = "This job was open for";
+$lang["job"][3]                = "Intervention is done, mark as old.";
+$lang["job"][4]                = "Assign intervention";
+$lang["job"][5]                = "Assigned to";
+$lang["job"][6]                = "Assign";
+$lang["job"][7]                = "Followups";
+$lang["job"][8]                = "No Followups for this intervention.";
+$lang["job"][9]                = "Post new Followup for this intervention";
+$lang["job"][10]       = "No Followups for this intervention.";
+$lang["job"][11]       = "Describe the Problem/Action";
+$lang["job"][12]       = "No Followups for this intervention.";
+$lang["job"][13]       = "Add a new intervention";
+$lang["job"][14]       = "New intervention";
+$lang["job"][15]       = "History";
+$lang["job"][16]       = "found";
+$lang["job"][17]    = "tracking";
+
+// Computers
+
+$lang["computers"][0]  = "Add Computer...";
+$lang["computers"][7]  = "Name";
+$lang["computers"][8]  = "Type";
+$lang["computers"][9]  = "OS";
+$lang["computers"][10] = "Location";
+$lang["computers"][11] = "Last modified";
+$lang["computers"][12] = "New Computer from template";
+$lang["computers"][13] = "Computer ID";
+$lang["computers"][14] = "Inserted";
+$lang["computers"][15] = "Contact#";
+$lang["computers"][16] = "Contact person";
+$lang["computers"][17] = "Serial# 1";
+$lang["computers"][18] = "Serial# 2";
+$lang["computers"][19] = "Comments";
+$lang["computers"][20] = "OS Version";
+$lang["computers"][21] = "CPU";
+$lang["computers"][22] = "MHZ";
+$lang["computers"][23] = "RAM Type";
+$lang["computers"][24] = "RAM (MB)";
+$lang["computers"][25] = "HD (GB)";
+$lang["computers"][26] = "Adapter";
+$lang["computers"][27] = "Flags";
+$lang["computers"][28] = "Server";
+$lang["computers"][29] = "";                                   // reserved
+$lang["computers"][30] = "";                                   // reserved
+$lang["computers"][31] = "ID";
+$lang["computers"][32] = "No Computer found.";
+$lang["computers"][33] = "Soundcard";
+$lang["computers"][34] = "Graphics card";
+$lang["computers"][35] = "Motherboard";
+$lang["computers"][36] = "HD-Type";
+$lang["computers"][37] = "No connected monitor.";
+$lang["computers"][38] = "No connected printer";
+$lang["computers"][39] = "Printers";
+$lang["computers"][40] = "Monitors";
+$lang["computers"][41]  = "Date of purchase ";
+$lang["computers"][42] = "Warranty expiration date";
+$lang["computers"][43] = "Maintenance";
+$lang["computers"][44]  = "Computers";
+$lang["computers"][45] = "Select a template";
+
+// Networking
+
+$lang["networking"][0] = "Name";
+$lang["networking"][1] = "Location";
+$lang["networking"][2] = "Type"; 
+$lang["networking"][3] = "Contact"; 
+$lang["networking"][4] = "Contact#"; 
+$lang["networking"][5] = "RAM (MB)"; 
+$lang["networking"][6] = "Serial# 1"; 
+$lang["networking"][7] = "Serial# 2"; 
+$lang["networking"][8] = "Comments"; 
+$lang["networking"][9] = "Last modification";
+$lang["networking"][10]        = ""; 
+$lang["networking"][11]        = "Add Netdevice..."; 
+$lang["networking"][12]        = "Networking device";
+$lang["networking"][13]        = "networking ports found"; 
+$lang["networking"][14]        = "IP"; 
+$lang["networking"][15]        = "MAC"; 
+$lang["networking"][16]        = "Interface"; 
+$lang["networking"][17]        = "Connected to"; 
+$lang["networking"][18]        = ""; 
+$lang["networking"][19]        = "Add networking port..."; 
+$lang["networking"][20]        = "Port Manager"; 
+$lang["networking"][21]        = "Logical Number"; 
+$lang["networking"][22]        = "Interface Address"; 
+$lang["networking"][23]        = "Interface MAC"; 
+$lang["networking"][24]        = "Connection"; 
+$lang["networking"][25]        = "on"; 
+$lang["networking"][26]        = "Not connected."; 
+$lang["networking"][27]        = "Connecting port"; 
+$lang["networking"][28]        = "(Step 1)"; 
+$lang["networking"][29]        = "to a computer whose";
+$lang["networking"][30]        = "contains"; 
+$lang["networking"][31]        = "Or choose a network device"; 
+$lang["networking"][32]        = "(Step 2)"; 
+$lang["networking"][33]        = "Choose a computer from the resultlist";
+$lang["networking"][34]        = "Device not connected : no port found.";
+$lang["networking"][35]        = "(last step)";
+$lang["networking"][36]        = "List of all ports on device";
+$lang["networking"][37]        = "Networking port found"; 
+$lang["networking"][38]        = "No computer found.";
+$lang["networking"][39]        = "Date of purchase";
+$lang["networking"][40]        = "Warranty expiration date";
+$lang["networking"][41]        = "Maintenance";
+$lang["networking"][42] = "Identifier";
+$lang["networking"][43] = "Networking";
+$lang["networking"][44] = "The port";
+$lang["networking"][45] = "is now connected on port";
+
+
+
+
+
+// Printers
+$lang["printers"][0]   = "Add Printer...";
+$lang["printers"][1]   = "View by location";
+$lang["printers"][2]   = "sorted by";
+$lang["printers"][3]   = "Add printer";
+$lang["printers"][4]   = "Printer";
+$lang["printers"][5]   = "Name";
+$lang["printers"][6]   = "Location";
+$lang["printers"][7]   = "Contact#";
+$lang["printers"][8]   = "Contact Person";
+$lang["printers"][9]   = "Type";
+$lang["printers"][10]  = "Serial# 1";
+$lang["printers"][11]  = "Serial# 2";
+$lang["printers"][12]  = "Comments";
+$lang["printers"][13]  = "Location";
+$lang["printers"][14]  = "Serial Interface";
+$lang["printers"][15]  = "Parallel Interface";
+$lang["printers"][16]  = "Last modification";
+$lang["printers"][17]  = "No printer found.";
+$lang["printers"][18]  = "Flags";
+$lang["printers"][19]  = "ID";
+$lang["printers"][20]   = "Date of purchase ";
+$lang["printers"][21]  = "Warranty expiration date";
+$lang["printers"][22]  = "Maintenance";
+$lang["printers"][23]   = "RAM";
+$lang["printers"][24]   = "Identifier";
+$lang["printers"][25]   = "Printers";
+
+
+// Monitors
+$lang["monitors"][0]   = "Add Monitor...";
+$lang["monitors"][3]   = "Add monitor";
+$lang["monitors"][4]   = "Monitor";
+$lang["monitors"][5]   = "Name";
+$lang["monitors"][6]   = "Location";
+$lang["monitors"][7]   = "Contact#";
+$lang["monitors"][8]   = "Contact Person";
+$lang["monitors"][9]   = "Type";
+$lang["monitors"][10]  = "Serial# 1";
+$lang["monitors"][11]  = "Serial# 2";
+$lang["monitors"][12]  = "Comments";
+$lang["monitors"][13]  = "Location";
+$lang["monitors"][14]  = "Microphone";
+$lang["monitors"][15]  = "Speakers";
+$lang["monitors"][16]  = "Last modification";
+$lang["monitors"][17]  = "No monitor found.";
+$lang["monitors"][18]  = "Flags";
+$lang["monitors"][19]  = "Sub-D";
+$lang["monitors"][20]  = "BNC";
+$lang["monitors"][21]  = "Size";
+$lang["monitors"][22]  = "Connected to";
+$lang["monitors"][23]  = "ID";
+$lang["monitors"][24]   = "Date of purchase ";
+$lang["monitors"][25]  = "Warranty expiration date";
+$lang["monitors"][26]  = "Maintenance";
+$lang["monitors"][27]   = "Identifier";
+$lang["monitors"][28]  = "Monitors";
+
+
+// Software
+$lang["software"][0]   = "Add Software..."; 
+$lang["software"][1]   = "ID"; 
+$lang["software"][2]   = "Name"; 
+$lang["software"][3]   = "Platform"; 
+$lang["software"][4]   = "Location"; 
+$lang["software"][5]   = "Version"; 
+$lang["software"][6]   = "Comments"; 
+$lang["software"][7]   = "Search Software"; 
+$lang["software"][8]   = "where"; 
+$lang["software"][9]   = "contains"; 
+$lang["software"][10]  = "Software";
+$lang["software"][11]  = "Licenses"; 
+$lang["software"][12]  = "Add license..."; 
+$lang["software"][13]  = "licenses found"; 
+$lang["software"][14]  = "No license for this software.";
+$lang["software"][15]  = "Add licenses to software"; 
+$lang["software"][16]  = "Serial Number (free for free)";
+$lang["software"][17]  = "Installed Software"; 
+$lang["software"][18]  = "License already installed."; 
+$lang["software"][19]  = "Installed";
+$lang["software"][20]  = "Remaining";
+$lang["software"][21]  = "Total";
+$lang["software"][22]  = "No Software found.";
+$lang["software"][23]   = "Software";
+
+
+// Reports
+$lang["reports"][0]    = "Select a report you want to generate";
+$lang["reports"][1]     = "Printers under maintenance contract";
+$lang["reports"][2]     = "Monitors under maintenance contract";
+$lang["reports"][3]     = "Network devices under maintenance contract";
+$lang["reports"][4]     = "List of the hardware under maintenance contract";
+$lang["reports"][5]     = "Computers under maintenance contract";
+
+// LDAP
+$lang["ldap"][0]       = "Search";
+$lang["ldap"][1]       = "Show";
+$lang["ldap"][2]       = "and";
+$lang["ldap"][3]       = "where the attribute";
+$lang["ldap"][4]       = "Add new entry...";
+$lang["ldap"][5]       = "required";
+$lang["ldap"][6]       = "allowed";
+$lang["ldap"][7]       = "LDAP";
+
+
+// Setup
+$lang["setup"][0]      = "Dropdowns";
+$lang["setup"][1]      = "Templates";
+$lang["setup"][2]      = "glpi Users";
+$lang["setup"][3]      = "Locations";
+$lang["setup"][4]      = "Computer Types";
+$lang["setup"][5]      = "Operating Systems";
+$lang["setup"][6]      = "RAM Types";
+$lang["setup"][7]      = "CPUs";
+$lang["setup"][8]      = "NICs";
+$lang["setup"][9]      = "Network Interfaces";
+$lang["setup"][10]     = "Inventory";
+$lang["setup"][11]     = "Change password for";
+$lang["setup"][12]     = "User";
+$lang["setup"][13]     = "Realname";
+$lang["setup"][14]     = "E-Mail";
+$lang["setup"][15]     = "Phone#";
+$lang["setup"][16]     = "Location";
+$lang["setup"][17]     = "Account Type";
+$lang["setup"][18]     = "Login";
+$lang["setup"][19]     = "Password";
+$lang["setup"][20]     = "Type";
+$lang["setup"][21]     = "Don't forget to set a password later!";
+$lang["setup"][22]     = "Add a template...";
+$lang["setup"][23]     = "Template name";
+$lang["setup"][24]     = "Name";
+$lang["setup"][25]     = "Location";
+$lang["setup"][26]     = "Contact#";
+$lang["setup"][27]     = "Contact Person";
+$lang["setup"][28]     = "Serial# 1";
+$lang["setup"][29]     = "Serial# 2";
+$lang["setup"][30]     = "Comments";
+$lang["setup"][31]     = "Type";
+$lang["setup"][32]     = "OS";
+$lang["setup"][33]     = "OS Version";
+$lang["setup"][34]     = "CPU";
+$lang["setup"][35]     = "MHZ";
+$lang["setup"][36]     = "RAM Type";
+$lang["setup"][37]     = "RAM (MB)";
+$lang["setup"][38]     = "HD (GB)";
+$lang["setup"][39]     = "NIC Type";
+$lang["setup"][40]     = "Display new jobs first?";
+$lang["setup"][41]     = "Select Language";
+$lang["setup"][42]     = "Networking Types";
+$lang["setup"][43]     = "Printer Types";
+$lang["setup"][44]     = "Monitor Types";
+$lang["setup"][45]     = "Mainboards";
+$lang["setup"][46]     = "Graphics Cards";
+$lang["setup"][47]     = "Soundcards";
+$lang["setup"][48]     = "Harddisk Types";
+$lang["setup"][49]     = "Mainboard";
+$lang["setup"][50]     = "Graphics Card";
+$lang["setup"][51]     = "Soundcard";
+$lang["setup"][52]     = "Harddisk Type";
+$lang["setup"][53]      = "Date purchase ";
+$lang["setup"][54]     = "Guaranteed expiration";
+$lang["setup"][55]     = "Maintenance";
+$lang["setup"][56]     = "Settings";
+$lang["setup"][57]      = "User Name";
+$lang["setup"][58]      = "Right of intervention assignement";
+$lang["setup"][59]      = "Setup the rights of intervention assignement";
+$lang["setup"][60]      = "No";
+$lang["setup"][61]      = "Yes";
+
+// Helpdesk
+
+$lang["help"][0]       = "Welcome";
+$lang["help"][1]       = "Please describe your problem";
+$lang["help"][2]       = "The problem must be solved";
+$lang["help"][3]       = "yesterday";
+$lang["help"][4]       = "Very quickly";
+$lang["help"][5]       = "In the course of the day";
+$lang["help"][6]       = "next week";
+$lang["help"][7]       = "when time is free";
+$lang["help"][8]       = "Inform me about the taken pursuant actions ";
+$lang["help"][9]       = "No";
+$lang["help"][10]      = "Yes";
+$lang["help"][11]      = "My E-Mail";
+$lang["help"][12]      = "My Machine-ID:";
+$lang["help"][13]      = "The Problem";
+$lang["help"][14]      = "Submit Message";
+$lang["help"][15]      = "No Description, please try again.";
+$lang["help"][16]      = "If you want be notified about the taken pursuant 
actions, you must enter your e-mail!";
+$lang["help"][17]      = "Please enter your Machine-ID!";
+$lang["help"][18]      = "Your message has been sent successfully, your 
request is in hand.";
+$lang["help"][19]      = "Thank you for using our automatic Helpdesk-System.";
+$lang["help"][20]      = "The description of your problem could not be added 
to our database.";
+$lang["help"][21]      = "Please contact your local system administrator.";
+
+  // Mois
+  $lang["calendarM"][0] = "January" ;
+  $lang["calendarM"][1] = "February" ;
+  $lang["calendarM"][2] = "March" ;
+  $lang["calendarM"][3] = "April" ;
+  $lang["calendarM"][4] = "May" ;
+  $lang["calendarM"][5] = "June" ;
+  $lang["calendarM"][6] = "July" ;
+  $lang["calendarM"][7] = "August" ;
+  $lang["calendarM"][8] = "September" ;
+  $lang["calendarM"][9] = "October" ;
+  $lang["calendarM"][10] = "November" ;
+  $lang["calendarM"][11] = "December" ;
+
+  // Première lettre des jours de la semaine
+  $lang["calendarD"][0] = "S" ;
+  $lang["calendarD"][1] = "M" ;
+  $lang["calendarD"][2] = "T" ;
+  $lang["calendarD"][3] = "W" ;
+  $lang["calendarD"][4] = "T" ;
+  $lang["calendarD"][5] = "F" ;
+  $lang["calendarD"][6] = "S" ;
+
+$lang["mailing"][0]="-----------------------";
+$lang["mailing"][1]="--------------------------------------";
+$lang["mailing"][2]="Author : ";
+$lang["mailing"][3]="Contents : ";
+$lang["mailing"][4]="Intervention(s) already done";
+$lang["mailing"][5]="Description of the intervention";
+$lang["mailing"][6]="Beginning's date : ";
+$lang["mailing"][7]="Computer concerned : ";
+$lang["mailing"][8]="Attributed to : ";
+$lang["mailing"][9]="New intervention's demand";
+$lang["mailing"][10]="New intervention's follow up";
+$lang["mailing"][11]="Intervention finished the ";
+$lang["mailing"][12]="Attribution of the intervention";
+$lang["mailing"][13]="Error in the automatic e-mail generation";
+?>
diff -udrN -x Entries cvs/glpi/setup/classes.php dev/glpi/setup/classes.php
--- cvs/glpi/setup/classes.php  2004-05-26 16:14:48.000000000 +0200
+++ dev/glpi/setup/classes.php  2004-05-28 15:10:06.000000000 +0200
@@ -37,21 +37,99 @@
 class User {
 
        var $fields     = array();
+
+  function User($name) {
+       $this->$fields['name'] = $name;
+       $this->$fields['password'] = '';
+       $this->$fields['email'] = $name;
+       $this->$fields['location'] = 'NULL';
+       $this->$fields['phone'] = 'NULL';
+       $this->$fields['type'] = 'post-only';
+       $this->$fields['realname'] = $name;
+       $this->$fields['can_assign_job'] = 'no';
+  }
        
        function getFromDB($name) {
                $db = new DB;
                $query = "SELECT * FROM users WHERE (name = '$name')";
                if ($result = $db->query($query)) {
                        $data = $db->fetch_array($result);
+                       if (empty($data)) {
+                               return false;
+                       }
                        foreach ($data as $key => $val) {
                                $this->fields[$key] = $val;
                        }
                        return true;
+               }
+               return false;
+       }
 
-               } else {
+       // Function that try to load from LDAP the user information...
+       //
+       function getFromLDAP($host,$basedn,$adm,$pass,$fields,$name)
+       {
+               // we prevent some delay..
+               if (empty($host)) {
                        return false;
                }
-       }
+       
+               // some defaults...
+               $this->fields['password'] = "";
+
+         if ( $conn = ldap_connect($host) )
+         {
+                       // switch to protocol version 3 to make ssl work
+                       ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3) ;
+               if ( $adm != "" )
+               {
+                               $dn = "uid=" . $adm . "," . $basedn;
+                       $bv = ldap_bind($conn, $dn, $pass);
+               }
+               else
+               {
+                       $bv = ldap_bind($conn);
+               }
+
+               if ( $bv )
+               {
+                       $f = array_values($fields);
+                       $sr = ldap_search($conn, $basedn, "uid=".$name, $f);
+                       $v = ldap_get_entries($conn, $sr);
+                       if ( (empty($v)) || empty($v[0][$fields['name']][0]) ) {
+                               return false;
+                       }
+                               foreach ($fields as $k => $e)
+                               {
+                                       $this->fields[$k] = $v[0][$e][0];
+                               }
+                               
+                               return true;
+               }
+       }
+       
+       return false;
+
+       } // getFromLDAP()
+
+
+  // Function that try to load from IMAP the user information... this is
+  // a fake one, as you can see...
+  function getFromIMAP($host, $name)
+  {
+               // we prevent some delay..
+               if (empty($host)) {
+                       return false;
+               }
+
+       // some defaults...
+       $this->fields['password'] = "";
+       $this->fields['email'] = $name . "@" . $host;
+
+               return true;
+
+       } // getFromIMAP()          
+
        
        function addToDB() {
                
@@ -97,7 +175,7 @@
                        $query  = "UPDATE users SET ";
                        $query .= $updates[$i];
                        $query .= "=";
-                       if ($updates[$i]=="password") {
+                       if ( ($updates[$i]=="password") && 
($this->fields[$updates[$i]] != "") ) {
                                $query .= 
"PASSWORD('".$this->fields[$updates[$i]]."')";
                        } else {
                                $query .= "'".$this->fields[$updates[$i]]."'";
diff -udrN -x Entries cvs/glpi/setup/functions.php dev/glpi/setup/functions.php
--- cvs/glpi/setup/functions.php        2004-05-26 16:14:48.000000000 +0200
+++ dev/glpi/setup/functions.php        2004-05-28 13:31:30.000000000 +0200
@@ -115,7 +115,7 @@
 
        GLOBAL $cfg_layout, $lang;
        
-       $user = new User;
+       $user = new User($ID);
        $user->getFromDB($ID);
                
        echo "<form method='post' action=\"$target\">";
@@ -136,7 +136,7 @@
 
        GLOBAL $cfg_layout, $lang;
        
-       $user = new User;
+       $user = new User($ID);
        $user->getFromDB($ID);
 
        echo "<center><table border='0' cellpadding=5>";
@@ -183,7 +183,7 @@
                $i = 0;
                while ($i < $db->numrows($result)) {
                        $name = $db->result($result,$i,"name");
-                       $user = new User;
+                       $user = new User($name);
                        $user->getFromDB($name);
                        
                        echo "<tr class='tab_bg_1'>";   
@@ -258,7 +258,7 @@
 function addUser($input) {
        // Add User, nasty hack until we get PHP4-array-functions
 
-       $user = new User;
+       $user = new User($input["name"]);
 
        // dump status
        $null = array_pop($input);
@@ -285,7 +285,7 @@
 function updateUser($input) {
        // Update User in the database
 
-       $user = new User;
+       $user = new User($input["name"]);
        $user->getFromDB($input["name"]); 
 
        // dump status
@@ -313,7 +313,7 @@
 function deleteUser($input) {
        // Delete User
        
-       $user = new User;
+       $user = new User($input["name"]);
        $user->deleteFromDB($input["name"]);
 } 
 
@@ -336,7 +336,7 @@
                  $i = 0;
                  while ($i < $db->numrows($result)) {
                        $name = $db->result($result,$i,"name");
-                       $user = new User;
+                       $user = new User($name);
                        $user->getFromDB($name);
                        
                        echo "<tr class='tab_bg_1'>";   
diff -udrN -x Entries cvs/login.php dev/login.php
--- cvs/login.php       2004-05-06 18:15:23.000000000 +0200
+++ dev/login.php       2004-05-28 15:10:57.000000000 +0200
@@ -54,129 +54,77 @@
 
 //Do login and checks
 //echo "test";
-$identificat = new Identification();
-
-// if use external sources for login
-if($cfg_login['use_extern'])
-{
-       //check for externals idents at remote imap/pop connection
-
-       $rem_host = $cfg_login['imap']['auth_server'];
-       
if($identificat->connection_imap($rem_host,$_POST['name'],$_POST['password']))
-       {
-               $ext_ident = 1;
-               $host = $cfg_login[imap]['host'];
-
-       }
-
-
-
-//to add another ext ident sources...
-//put it on the glpi/glpi/config/config.php
-//if(!(ext_ident))
-//{   connection test
-//             if success $ect_ident = 1; $host ="String host"} .... etc
-//example :
-//to connect on another IMAP source named $cfg_login['imap2'] on config.php :
-//if(!($ext_ident))
-//{
-//$rem_host = $cfg_login['imap2']['auth_server'];
-//if($identificat->connection_imap($rem_host,$_POST['name'],$_POST['password']))
-//{
-//             $ext_ident = 1;
-//             $host = $cfg_login[imap]['host'];
-//
-//}
-//}
+$identificat = new Identification($_POST['name']);
 
+// we check all the auth sources in turn...
+$auth_succeded = 
$identificat->connection_imap($cfg_login['imap']['auth_server'],$_POST['name'],$_POST['password']);
+if (!$auth_succeded) {
+       $auth_succeded = 
$identificat->connection_ldap($cfg_login['ldap']['host'],$cfg_login['ldap']['basedn'],$_POST['name'],$_POST['password']);
+}
+if (!$auth_succeded) {
+       $auth_succeded = 
$identificat->connection_db($_POST['name'],$_POST['password']);
+}
 
+// we have done at least a good login? No, we exit.
+if ( ! $auth_succeded ) {
+       nullHeader("Login",$_SERVER["PHP_SELF"]);
+       echo "<center><b>".$identificat->getErr().".</b><br><br>";
+       echo "<b><a 
href=\"".$cfg_install["root"]."/logout.php\">Relogin</a></b></center>";
+       nullFooter();
+       logevent(-1, "system", 1, "login", "failed login: ".$_POST['name']);
+       exit;
+}
 
+// now we have to load data for that user, we try all the data source in turn.
+// The constructor for Identification() have just filed the data with correct
+// stub
+$user_present = $identificat->user->getFromDB($_POST['name']);
+$update_list = array();
+if 
($identificat->user->getFromIMAP($cfg_login['imap']['host'],$_POST['name'])) {
+       $update_list = array('email');
+}
+if 
($identificat->user->getFromLDAP($cfg_login['ldap']['host'],$cfg_login['ldap']['basedn'],$cfg_login['ldap']['rootdn'],$cfg_login['ldap']['pass'],$cfg_login['ldap']['fields'],$_POST['name']))
 {
+       $update_list = array_keys($cfg_login['ldap']['fields']);
 }
 
-$conn = $identificat->connection_db_mysql($_POST['name'],$_POST['password']);
+// Ok, we have gathered sufficient data, if the first return false the user
+// are not present on the DB, so we add it.
+// if not, we update it.
+if (!$user_present) {
+       $identificat->user->addToDB();
+} else if (!empty($update_list)) {
+       $identificat->user->updateInDB($update_list);
+}
 
+// now we can continue with the process...
+$identificat->setcookies();
 
-switch ($conn)
+// If no prefs for user, set default
+$query = "SELECT * FROM prefs WHERE (user = '".$_POST['name']."')";
+$result = $db->query($query);
+if ($db->numrows($result) == 0)
 {
+       $query = "INSERT INTO prefs VALUES ('".$_POST['name']."', 
'yes','french')";
+       $result = $db->query($query);
+}
 
-       case 1:
-       {//Login failed no such user/password in DB
-
-               //if no external ident or all external ident failled
-               if(!($ext_ident))
-               {
-
-                       nullHeader("Login",$_SERVER["PHP_SELF"]);
-                       echo 
"<center><b>".$identificat->getErr().".</b><br><br>";
-                       echo "<b><a 
href=\"".$cfg_install["root"]."/logout.php\">Relogin</a></b></center>";
-                       nullFooter();
-                       logevent(-1, "system", 1, "login", "failed login: 
".$_POST['name']);
-                       break;
-
-               }
-               else
-               {
-               //if an external ident has been successfull: add the user to 
the DB or update
-               //his password if allready exist
-                       $identificat->add_an_user($_POST['name'], 
$_POST['password'], $host);
-                       $conn = 
$identificat->connection_db_mysql($_POST['name'],$_POST['password']);
-                       $login_ok = 1;
-                       break;
-               }
-       }
-       case 2:
-       {//good login
-
-               $login_ok = 1;
-               break;
+// Log Event
+logEvent("-1", "system", 3, "login", $_POST['name']." logged in.");
 
-       }
-       case 0:
-       {
+// Expire Event Log
+$secs =  $cfg_features["expire_events"]*86400;
+$db_exp = new DB;
+$query_exp = "DELETE FROM event_log WHERE UNIX_TIMESTAMP(date) < 
UNIX_TIMESTAMP()-$secs";
+$result_exp = $db_exp->query($query_exp);
 
-               //login failed No response from DB
-               nullHeader("Login",$_SERVER["PHP_SELF"]);
-               echo "<center><b>".$identificat->getErr().".</b><br><br>";
-               echo "<b><a 
href=\"".$cfg_install["root"]."/logout.php\">Relogin</a></b></center>";
-               nullFooter();
-               logevent(-1, "system", 1, "login", "failed login: 
".$_POST['name']);
-               break;
-       }
+// Redirect to Command Central if not post-only
+if ($identificat->user->fields['type'] == "post-only")
+{
+       header("Location: helpdesk.php?".SID);
 }
-
-if($login_ok)
+else
 {
-//good login
-
-
-                       $identificat->setcookies();
-
-                       // If no prefs for user, set default
-                       $query = "SELECT * FROM prefs WHERE (user = 
'".$_POST['name']."')";
-                       $result = $db->query($query);
-                       if ($db->numrows($result) == 0)
-                       {
-                               $query = "INSERT INTO prefs VALUES 
('".$_POST['name']."', 'yes','french')";
-                               $result = $db->query($query);
-                       }
-
-                       // Log Event
-                       logEvent("-1", "system", 3, "login", $_POST['name']." 
logged in.");
-
-                       // Expire Event Log
-                       $secs =  $cfg_features["expire_events"]*86400;
-                       $db_exp = new DB;
-                       $query_exp = "DELETE FROM event_log WHERE 
UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP()-$secs";
-                       $result_exp = $db_exp->query($query_exp);
-
-                       // Redirect to Command Central if not post-only
-                       if ($identificat->user->fields['type'] == "post-only")
-                       {
-                               header("Location: helpdesk.php?".SID);
-                       }
-                       else
-                       {
-                               header("Location: central.php?".SID);
-                       }
+       header("Location: central.php?".SID);
 }
+
 ?>
diff -udrN -x Entries cvs/logout.php dev/logout.php
--- cvs/logout.php      2004-05-06 18:15:01.000000000 +0200
+++ dev/logout.php      2004-05-28 12:44:21.000000000 +0200
@@ -44,7 +44,7 @@
 //SetCookie("IRMName", "bogus", 0, "/");
 //SetCookie("IRMPass", "bogus", 0, "/");
 session_start();
-$id = new Identification;
+$id = new Identification('bogus');
 $id->eraseCookies();
 
 // Redirect to the login-page

Reply via email to