LDAPAuthPHPPHP的LDAP认证
LDAPAuthPHP 用来在 PHP 程序中执行 LDAP 身份验证。
示例代码:
<?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)
}
