Adding LDAP AuthN and AuthZ in PHP applications is a very easy thing with LDAPAuthPHP.
An usage example (there are a lot of different ways):
<?php
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":
".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
session_name('MYAPP');
session_start();
if (!isset($_SESSION["user"])) {
include("LdapAuth.inc.php");
$ldap=new LdapAuth();
$ldap->setSessionAttr("user","uid");
$ldap->setSessionName("MYAPP");
$ldap->setRedirectPage($pageURL);
//page where we get redirected after login (in this case self)
include("LdapStandalonePageProtector.inc.php");
}
else {
echo "Logged In As: ".$_SESSION["user"]."</hr>";
//paste here the old page code (or write the new page to protect)
}