?
Solved

Get computer name and login name?

Posted on 2005-03-24
8
Medium Priority
?
213 Views
Last Modified: 2008-02-01
Is there a way to get a users computer name and login name through PHP? If so, how?
0
Comment
Question by:Breadstick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Author Comment

by:Breadstick
ID: 13622786
(in php or javascript...)
0
 
LVL 2

Author Comment

by:Breadstick
ID: 13623109
(or... java as a last resort?)
0
 
LVL 13

Accepted Solution

by:
StormyWaters earned 200 total points
ID: 13623325
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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 20

Expert Comment

by:virmaior
ID: 13623988
is it on a local area network or over the internet?
0
 
LVL 3

Expert Comment

by:Timothy Golden
ID: 13625223
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
 
LVL 2

Author Comment

by:Breadstick
ID: 13627421
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
 
LVL 2

Author Comment

by:Breadstick
ID: 13627435
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
 
LVL 3

Expert Comment

by:Timothy Golden
ID: 13629336
i should have mentioned that script was for used on a Windows server running PHP
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question