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?
Technology Partners: 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!


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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

717 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