From e5307c181fbdaef3536c74101cd75130640e541e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 3 Jan 2007 23:57:14 +0000 Subject: [PATCH] Ajout pour tester MDB2 --- htdocs/main.inc.php | 55 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 10b038ab36d..68d94155f93 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -66,9 +66,11 @@ $bc[1]="class=\"pair\""; // plusieurs modes sont indiqués. // Exemple: array('http','dolibarr'); // Exemple: array('ldap'); + //$authmode=array('ldap'); +//$authmode=array('http','dolibarr_mdb2'); $authmode=array('http','dolibarr'); -//$authmode=array('ldap'); + if (isset($dolibarr_auto_user)) $authmode=array('auto'); $sessionname="DOLSESSID_".$dolibarr_main_db_name; @@ -147,6 +149,57 @@ if (! session_id() || ! isset($_SESSION["dol_login"])) } exit; } + } + + // MODE DOLIBARR MDB2 + // Ajout du mode MDB2 pour test uniquement + if (in_array('dolibarr_mdb2',$authmode) && ! $login) + { + require_once(DOL_DOCUMENT_ROOT."/includes/pear/Auth/Auth.php"); + + $pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name; + + if ($conf->password_encrypted) + { + $cryptType = "md5"; + } + else + { + $cryptType = "none"; + } + + $params = array( + "dsn" => $pear, + "table" => MAIN_DB_PREFIX."user", + "usernamecol" => "login", + "passwordcol" => "pass", + "cryptType" => $cryptType, + ); + + $aDol = new DOLIAuth("MDB2", $params, "dol_loginfunction"); + $aDol->setSessionName($sessionname); + $aDol->start(); + $result = $aDol->getAuth(); // Si deja logue avec succes, renvoie vrai, sinon effectue un redirect sur page loginfunction et renvoie false + if ($result) + { + // Authentification Auth OK, on va chercher le login + $login=$aDol->getUsername(); + dolibarr_syslog ("Authentification ok (en mode Pear Base Dolibarr)"); + } + else + { + if (isset($_POST["loginfunction"])) + { + // Echec authentification + dolibarr_syslog("Authentification ko (en mode Pear Base Dolibarr) pour '".$_POST["username"]."'"); + } + else + { + // Non authentifie + //dolibarr_syslog("Authentification non realise"); + } + exit; + } } // MODE LDAP