Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Get computer name and login name?

Is there a way to get a users computer name and login name through PHP? If so, how?
1 Solution
BreadstickAuthor Commented:
(in php or javascript...)
BreadstickAuthor Commented:
(or... java as a last resort?)
No, you most certainly can't with PHP. PHP is on the serverside, the computer is the clientside. You can't with Javascript, either, as that would constitute a security risk. You might be able to with some ActiveX (IE only) but there will be security confirmations the user must agree to.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

is it on a local area network or over the internet?
Timothy GoldenBrand AmbassadorCommented:
this might work..

     Getting netbios info
    /* get the ip of the client */
    if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
    } else {
     $ip = $_SERVER["REMOTE_ADDR"];
    echo 'ip : '.$ip.'<br>';
    /* send a "special" packet */
    $fp = fsockopen('udp://'.$ip, 137);
    fwrite($fp, "\x80b\0\0\0\1\0\0\0\0\0\0 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!\0\1");

    /* wait 2 secs, and get the data */
    socket_set_timeout($fp, 2);
    $data = fread($fp, 256);
    /* get netbios records number */
    $nbrec = ord($data[56]);
    /* display nebios records : the username is a record of type 3 */
    echo '<strong>this is the netbios info</strong><br><table border="1">';
    echo '<tr><th>no</th><th>type</th><th>value</th></tr>';
    for($i = 0; $i < $nbrec; $i++) {
     $offset = 18 * $i;
     printf ("<tr><td>%02d</td><td>%02X</td><td>%s</td></tr>",
         ord($data[72 + $offset]),
         trim(substr($data, 57 + $offset, 15)));
    echo '</table>';

BreadstickAuthor Commented:
That doesn't seem to be working... it's displaying something like this:

ip :

Notice: Uninitialized string offset: 56 in C:\server\Apache2\htdocs\test.php on line 26
this is the netbios info
no      type      value
BreadstickAuthor Commented:
Oh... I tested that through my ip address instead of through 'localhost' and I was able to get my computer name.  But is that the servers computer name? Or the computer name of the user that is viewing the page?

And is there a way to display the users login name?
Timothy GoldenBrand AmbassadorCommented:
i should have mentioned that script was for used on a Windows server running PHP

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now