?
Solved

nbtstat - multiple login problems

Posted on 2001-07-19
7
Medium Priority
?
660 Views
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?

Eric
0
Comment
Question by:theravada_maha
[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
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:schmiegu
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).
0
 

Author Comment

by:theravada_maha
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?

Eric
0
 
LVL 56

Expert Comment

by:andyalder
ID: 6299534
If you set the netbios node type to B-node does nbtstat query the machine or does it ask the browsemaster?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

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

Eric
0
 

Author Comment

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

Eric
0
 
LVL 9

Accepted Solution

by:
schmiegu earned 300 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 www.microsoft.com or msdn.microsoft.com).
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).
0
 

Author Comment

by:theravada_maha
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?

Eric
0

Featured Post

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

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

Nslookup is a command line driven utility supplied as part of most Windows operating systems that can reveal information related to domain names and the Internet Protocol (IP) addresses associated with them. In simple terms, it is a tool that can …
We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
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 (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

800 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