0
是否可以顯示登錄後身份驗證的人員?PHP LDAP身份驗證爲
我的代碼包含登錄和工作:
HTML:
<form action="index.php" method="POST">
User:
<input type="text" name="username" /><br>
Pwd:
<input type="password" name="password" /><br>
<input type="submit" value="Login">
</form>
PHP:
<?php
$ldapServer = 'ldap://myServer';
$ldapPort = myPort;
$username = $_POST['username']."@myDomain.local";
$password = $_POST['password'];
$connect = ldap_connect($ldapServer, $ldapPort) or die("Connection failed!.");
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
if (@ldap_bind($connect, $username, $password)) {
echo "Authenticated";
}
else {
echo "Wrong Username or Password";
}
當我開始LDP.EXE PROGRAMM它讓我看到 自民黨。 exe:
0 = ldap_set_option(ld, LDAP_OPT_ENCRYPT, 1)
res = ldap_bind_s(ld, NULL, &NtAuthIdentity, NEGOTIATE (1158)); // v.3
{NtAuthIdentity: User='myUserName'; Pwd=<unavailable>; domain = 'myDomain.local'}
Authenticated as: 'MYDOMAIN\myUser'.
問題是我如何提取並將其呈現給我正確身份驗證的html頁面。
當然,你可以只'回聲$ username'顯示誰是登錄的代碼?將該值存儲在'$ _SESSION'中以在其他頁面中引用它。 – timclutton