Reputation: 1231
is this possible to show who is authenticated after the login ?
my code contains the login and is working:
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";
}
when i start the ldp.exe programm it shows me the ldp.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'.
the question is how can i extract and render it to the html page who i correctly autheticated.
Upvotes: 0
Views: 160
Reputation: 1231
for the record: solution for my problem: I put the code between the if statement
$filter = "(samAccountName=$user)";
$search = ldap_search($connect, $base_dn, $filter);
$info = ldap_get_entries($connect, $search);
echo "Logged In";
for($i=0; $i<$info["count"]; $i++) {
if($info['count'] > 1) break;
echo "<p>Hello, <strong> ". $info[$i]["sn"][0] .", " . $info[$i]["givenname"][0] ."</strong><br /> (" . $info[$i]["samaccountname"][0] .")</p>\n";
}
Upvotes: 1