LDAPAuthPHPPHP的LDAP认证

联合创作 · 2023-10-01 06:05

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)
}

浏览 3
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报