Solved

nbtstat - multiple login problems

Posted on 2001-07-19
7
651 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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