<?
require_once("includes.php");
session_start();
if (isset($_GET["clearsession"]))
session_unset();
if (isset($_SESSION["bind_dn"]))
die("error: session already bound");
if (isset($_GET["submitted"])) {
if (!empty($_GET["username"]) && !(empty($_GET["ldapdn"])))
die("error: use of username and DN are mutually exclusive.");
if (!empty($_GET["username"]))
$ldapdn = LDAP_USER_KEY . "=" . $_GET["username"] . "," .
LDAP_BASE_DN_PEOPLE;
else
$ldapdn = $_GET["ldapdn"];
if (empty($_GET["password"]))
die("error: no password given!!!");
if (!do_ldap_connect($ldapdn, $_GET["password"]))
die(sprintf("ldap_bind failed as %s (bad password?)", $ldapdn));
$_SESSION["bind_user"] = $_GET["username"];
$_SESSION["bind_pass"] = $_GET["password"];
$_SESSION["bind_dn"] = $ldapdn;
if (isset($_SESSION["requested"]))
redirect($_SESSION["requested"]);
else {
pagehead("Corporate Directory - Logged in",
"Login Page", MENU_NAVBAR_HEADER);
?>
<p>
<hr>
You are now logged in. Please select one of the pages from the
navigation links above.
<? }
} else {
pagehead("Corporate Directory - Login", "Login Page", NULL);
?>
<p>
Please enter your Corporate login to access these directory pages.
<p>
Your login credentials will allow you to make modifications to
directory entries that you are listed as the owner of, and to
see all of the information available to you specifically.
<p>
You can login as your normal username, or as a specific
LDAP Distinguished Name (i.e., for administrative access).
<hr>
<form action="/<?echo(LOGINPAGE)?>">
<input type=hidden name=submitted>
<p>
Username:
<input type=text name=username size=20 maxlength=40>
<strong> -OR- </strong>
LDAP DN:
<input type=text name=ldapdn size=40 maxlength=80>
<br>
Password:
<input type=password name=password size=20 maxlength=20>
<p>
<input type=submit value=login>
</form>
<?
}
pagefoot();
?>