nbtstat - multiple login problems

Posted on 2001-07-19
Last Modified: 2013-12-23
We've made a PHP page that runs the command nbtstat -A [IP number] and grabs the results, sorts through them and finds the user's login name for that IP accessing the php page. Here's the code for your information, it works fine:

function GetLoginName ($IP) {
     exec("nbtstat -A $IP",$Lines);
     $Lines = KeepIf($Lines, "LineIsUser");
     $Lines = ArrMap ($Lines, "BeforeFirstSpace");
     $Lines = KeepIf($Lines, "Alphabetical");
        return $Lines[0];

But we ran into a problem. If I log into my machine and the machine next to me with the same username, problems arise. If I run nbtstat on the machine on which I logged in last, I can't find a username in the list, only the domain name and the computer name. So this obviously isn't good since people are going to access this page and will have to be sure they logged off other machines. I want nbtstat to always return the user's login name, but right now it doesn't seem possible.

Is there any way around this? What can be done?

Question by:theravada_maha
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
  • 4
  • 2

Expert Comment

ID: 6299452
With nbtstat you only get the username registered in WINS/NetBIOS - and this can only be once! (Always the first registration, if you log on a second time, you get an error about duplicate name on the network in event viewer).

What you can do is to either get the environment variable %username% or the username property from the network object (both in Scripting Host).

Author Comment

ID: 6299489
"What you can do is to either get the environment variable %username% or the username property from the
network object (both in Scripting Host)."

This would be very helpful, can you explain how I go about doing this?

LVL 55

Expert Comment

ID: 6299534
If you set the netbios node type to B-node does nbtstat query the machine or does it ask the browsemaster?
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.


Author Comment

ID: 6299571
I have no idea what you mean, I'm not the network administrator if that has anything to do with it.


Author Comment

ID: 6299592
I have no idea what you mean, I'm not the network administrator if that has anything to do with it.


Accepted Solution

schmiegu earned 100 total points
ID: 6299776
It's not really important, but whichever node you set, nbtstat -A (and -a) show the nametable of the remote machine (same as nbtstat -n on the remote machine itself).

Is your PHP page something like a login script? If yes, Windows script host is the solution (if it's onstalled on th eclients). If you have installed WSH, you should find WSH.CHM on your machine along with enough sample code to get your work done. (If the helpfile isn't there, you should find it on or
If it's not a login script, then I was to enthusiastic. You still can do the job with an ActiveX enabled scripting language, but you need WMI installed and I don't find it easy to program (maybe it could be done with ADSI also, which I'm more familiar with and which I find easier to handle, but I never tried something like you want to do).

Author Comment

ID: 6299953
The page simply takes your ip number and then uses that and nbtstat to find you in a database and pull information on you. I have no idea how to use WMI, so is there any hope?


Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to best manage folder and file security 4 127
SQL Server Communications Audit 5 126
AD Account Lockout 22 72
Disabling energy efficient ethernet on all hardware models 6 86
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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