/** * Plug-in pour creation de comptes CAS */ function main($content, $conf) { $this->conf = $conf; $this->pi_setPiVarDefaults(); $this->pi_USER_INT_obj = 1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! $this->pi_loadLL(); $this->ldapParam = array('server' => "10.211.162.20", 'port' => "10389", 'basedn' => "ou=utilisateurs,dc=haras-nationaux-dev,dc=fr"); session_start(); $content = ''; if (!isset($this->piVars["action"])) { $content = $this->getFormulaireVide(); } else { if (isset($this->piVars["action"]) && $this->piVars["action"] == "insert") { if (!$this->checkLogin($this->piVars["login"])) { $content = '<h3>' . nl2br(htmlspecialchars($this->pi_getLL("error_login_format"))) . '<br/></h3>'; $content .= $this->getFormulaireVide(); return $this->pi_wrapInBaseClass($content); } if ($this->piVars["action"] == "" || $this->piVars["login"] == "" || $this->piVars["passwd1"] == "" || $this->piVars["passwd2"] == "") { $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_missing_field")) . '<br/></h3>'; $content .= $this->getFormulaireVide(); } else { if (!$this->checkLogin($this->piVars["login"])) { $content = '<h3>' . nl2br(htmlspecialchars($this->pi_getLL("error_login_format"))) . '<br/></h3>'; $content .= $this->getFormulaireVide(); } else { if (strlen($this->piVars["passwd1"]) < 6 || strlen($this->piVars["login"]) < 6) { $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_min_field")) . '<br/></h3>'; $content .= $this->getFormulaireVide(); } else { if ($this->piVars["passwd1"] != $this->piVars["passwd2"]) { $content = '<h3>' . htmlspecialchars($this->pi_getLL("error_passwd_not_match")) . '<br/></h3>'; $content .= $this->getFormulaireVide(); } else { $ws = new WebservicesCompte($this->typeExecution); if (!$ws->connectServices()) { $content = "ERROR:" . $ws->getErrorMessage(); } else { if ($this->loginExistinLdap($this->piVars["login"])) { $content = $this->errorLoginExiste(); } else { $md5 = "{MD5}" . base64_encode(mhash(MHASH_MD5, $this->piVars["passwd1"])); //$md5 = $this->piVars["passwd1"]; $param = array("in0" => $this->piVars["login"], "in1" => $md5, "in2" => ""); $result = $ws->createCompte($param)->out; if ($ws->getErrorMessage() != "") { $content = '<font color="red">' . $ws->getErrorMessage . '</font><br/>'; } if ($result == "0" || $result == "") { $content = $this->success(); } else { if ($result == "1945") { $content = $this->errorLoginExiste(); } else { if ($result == "1944") { $content = "ERREUR SERVEUR LOGIN ET OU MOT DE PASSE VIDENT<br/>"; /*$content.="--------TRACE-------<br/>"; $content.="login:"******"login"]."<br/>"; $content.="passwd:".$this->piVars["passwd1"]."<br/>"; $content.="passwd_md5:".$md5."<br/>"; $content.="resultat du WS:".$result["createCompteCasForPortailReturn"];*/ } else { $content = "ERREUR INCONNUE" . $result . ":<br/>"; /*$content.="--------TRACE-------<br/>"; $content.="login:"******"login"]."<br/>"; $content.="passwd:".$this->piVars["passwd1"]."<br/>"; $content.="passwd_md5:".$md5."<br/>"; $content.="resultat du WS:".$result["createCompteCasForPortailReturn"];*/ } } } } } } } } } } else { $content = "<h1>error</h1>"; } } return $this->pi_wrapInBaseClass($content); }