Solved

nbtstat - multiple login problems

Posted on 2001-07-19
7
645 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
  • 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 55

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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 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 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now