0

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.

1
  • Surely you can just echo $username to show who is logged in? Store that value in $_SESSION to reference it in other pages. Commented Jul 3, 2017 at 13:39

1 Answer 1

1

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";
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.