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

x
  • 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?
0
Breadstick
Asked:
Breadstick
1 Solution
 
BreadstickAuthor Commented:
(in php or javascript...)
0
 
BreadstickAuthor Commented:
(or... java as a last resort?)
0
 
StormyWatersCommented:
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.
0
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.

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

<?php
    /*
     Getting netbios info
    */    
   
    error_reporting(E_ALL);
   
    /* get the ip of the client */
    if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
 {
     $ip = $_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>",
         $i,
         ord($data[72 + $offset]),
         trim(substr($data, 57 + $offset, 15)));
    }
    echo '</table>';
   

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

ip : 127.0.0.1

Notice: Uninitialized string offset: 56 in C:\server\Apache2\htdocs\test.php on line 26
this is the netbios info
no      type      value
0
 
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?
0
 
Timothy GoldenBrand AmbassadorCommented:
i should have mentioned that script was for used on a Windows server running PHP
0

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