2003-03-14 11:32:28 +00:00
|
|
|
<?
|
2003-03-13 19:48:49 +00:00
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
|
|
|
Copyright (C) 2003 Michael Duergner
|
|
|
|
|
|
|
|
This program 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.
|
2003-03-14 11:32:28 +00:00
|
|
|
|
2003-03-13 19:48:49 +00:00
|
|
|
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.
|
2003-03-14 11:32:28 +00:00
|
|
|
|
2003-03-13 19:48:49 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
2003-03-14 11:32:28 +00:00
|
|
|
|
|
|
|
LDAP Account Manager checking login data.
|
2003-03-13 19:48:49 +00:00
|
|
|
*/
|
2003-03-18 20:55:43 +00:00
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
include_once("../config/config.php"); // Include config.php which provides Config class
|
|
|
|
|
|
|
|
// Get session save path
|
|
|
|
$path = getcwd();
|
|
|
|
$path = explode("/", substr($path,1));
|
|
|
|
for($i = 0; $i < (count($path) - 1); $i++)
|
|
|
|
{
|
|
|
|
$session_save_path .= "/" . $path[$i];
|
|
|
|
}
|
|
|
|
$session_save_path .= "/sess";
|
|
|
|
|
|
|
|
session_save_path($session_save_path); // Set session save path
|
|
|
|
@session_start(); // Start LDAP Account Manager session
|
2003-03-28 15:45:42 +00:00
|
|
|
// generate 256 bit key and initialization vector for user/passwd-encryption
|
|
|
|
$key = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
|
|
|
|
$iv = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
|
|
|
|
|
|
|
|
// save both in cookie
|
|
|
|
setcookie("Key", base64_encode($key));
|
|
|
|
setcookie("IV", base64_encode($iv));
|
2003-03-20 20:25:40 +00:00
|
|
|
|
2003-03-14 11:32:28 +00:00
|
|
|
// checking if the submitted username/password is correct.
|
|
|
|
if($action == "checklogin")
|
|
|
|
{
|
2003-03-23 14:41:15 +00:00
|
|
|
include_once("../lib/ldap.php"); // Include ldap.php which provides Ldap class
|
2003-03-20 16:41:52 +00:00
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
$ldap = new Ldap($config); //$config); // Create new Ldap object
|
|
|
|
$result = $ldap->connect($username,$passwd); // Connect to LDAP server for verifing username/password
|
|
|
|
if($result == True) // Username/password correct. Do some configuration and load main frame.
|
2003-03-14 11:32:28 +00:00
|
|
|
{
|
2003-03-18 19:40:30 +00:00
|
|
|
// setting language
|
|
|
|
$language = explode(":", $language);
|
|
|
|
putenv("LANG=" . $language[1]);
|
2003-04-02 20:56:41 +00:00
|
|
|
setlocale(LC_ALL, $language[0]);
|
2003-03-18 19:40:30 +00:00
|
|
|
bindtextdomain("lam", "../locale");
|
|
|
|
textdomain("lam");
|
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
include("./main.php"); // Load main frame
|
2003-03-20 20:25:40 +00:00
|
|
|
|
2003-03-20 16:53:44 +00:00
|
|
|
session_register("ldap"); // Register $ldap object in session
|
|
|
|
session_register("language"); // Register $language in session
|
2003-03-14 11:32:28 +00:00
|
|
|
}
|
2003-03-15 12:13:49 +00:00
|
|
|
else
|
2003-03-14 11:32:28 +00:00
|
|
|
{
|
2003-03-15 12:13:49 +00:00
|
|
|
if($ldap->server)
|
|
|
|
{
|
|
|
|
$error_message = "Wrong Password/Username combination. Try again.";
|
2003-03-23 14:41:15 +00:00
|
|
|
include("./login.inc"); // Username/password invalid. Return to login page.
|
2003-03-15 12:13:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$error_message = "Cannot connect to specified LDAP-Server. Try again.";
|
2003-03-23 14:41:15 +00:00
|
|
|
include("./login.inc"); // Server not reachable. Return to login page.
|
2003-03-15 12:13:49 +00:00
|
|
|
}
|
2003-03-14 11:32:28 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-23 14:41:15 +00:00
|
|
|
// Load login page
|
2003-03-14 11:32:28 +00:00
|
|
|
else
|
|
|
|
{
|
2003-03-20 16:37:20 +00:00
|
|
|
session_register("config"); // Register $config object in session
|
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
include_once("../lib/ldap.php"); // Includ ldap.php which provides Ldap class
|
2003-03-20 16:41:52 +00:00
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
$config = new Config; // Create new Config object
|
2003-03-20 16:37:20 +00:00
|
|
|
|
2003-03-23 14:41:15 +00:00
|
|
|
include("./login.inc"); // Load login page
|
2003-03-14 11:32:28 +00:00
|
|
|
}
|
|
|
|
?>
|