使用adLDAP显示登录的用户名

索比

我正在使用adLDAP登录到我正在构建的Intranet站点。我刚开始使用LDAP集成,并且在这个游戏中我比较新鲜。

我已经设法使用adLDAP库进行身份验证和登录,但是我想在用户登录后显示其全名。

这是我正在使用的登录脚本。基本上与adLDAP示例相同。

<?php
//log them out
$logout = $_GET['logout'];
if ($logout == "yes") { //destroy the session
session_start();
$_SESSION = array();
session_destroy();
}

//you should look into using PECL filter or some form of filtering here for POST variables
$username = strtoupper($_POST["username"]); //remove case sensitivity on the username
$password = $_POST["password"];
$formage = $_POST["formage"];

if ($_POST["loginform"]) { //prevent null bind

if ($username != NULL && $password != NULL){
    //include the class and create a connection
    include (dirname(__FILE__) . "/src/adLDAP.php");
    try {
        $adldap = new adLDAP();
    }
    catch (adLDAPException $e) {
        echo $e; 
        exit();   
    }

    //authenticate the user
    if ($adldap->authenticate($username, $password)){
        //establish your session and redirect
        session_start();
        $_SESSION["username"] = $username;
        $_SESSION["loggedin"] = true;
        $redir = "Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/loggedin.php";
        header($redir);
        exit;
    }
}
$failed = 1;
}

?>

在登录页面上,我有以下代码:

<?php
session_start();
?>
<?php
$redir = "Location: /Kart";
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {

    include ("main.php");

} else {
    header($redir);
}
?>

在main.php中,我尝试包含类似

<strong>Welcome </strong><?php printf("<b><i>$firstname $lastname</i></b>"); ?> - <a href="Logout.php">click here to log out</a>!

如何在此处显示已登录用户的全名?

谢谢!

马塞尔·伯克哈德(Marcel Burkhard)

您在adldap中寻找的属性是displayName

检查文档:http : //adldap.sourceforge.net/wiki/doku.php?id= documentation_user_functions# infocollection_username_fields_null

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章