Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2366
  • Last Modified:

Finding the NetBIOS computer name for a given username

I am looking for a way, either using an external program, or as part of a vbscript, to take a username and find out the NetBIOS name of the computer that the user is logged on to. I know that one can use "nbtstat" to determine what user is logged on to a given computer, but I'd like to do it the other way around, preferably without having to poll every machine on the network.

I understand that the "net send" command can take a username as the destination and somehow it finds its way to the computer to which the given user is logged on. What would be extremely helpful is either an idea for how to code this sort of function in vbscript, or even if someone knows of a program that can do this task. If there is a program that does this, then I could just save its output as a textfile and use it in the script I am writing. If you need any more info, don't hesitate to ask! Thanks :-)
0
Abyzmal
Asked:
Abyzmal
1 Solution
 
Goliath_Commented:
the only easy way i see to do that, is that user login script writes the computername associate with their username into a DB or even a flat text file and then you can take a search into that from another vbscript...

thanks!
0
 
BaDaBooMCommented:
This may be more involved than you want to get, but there is a tool in the Windows 2000 resource kit that can do this and even store it in a SQL database.  The name of the file is Cconnect.exe.  It can also limit concurrent connections.  Look for it in the resource kit documentation.
0
 
AbyzmalAuthor Commented:
Let's say that all the machines are connected to a Windows 2000 network server (active directory). Is there a way to poll the server to lookup the computername for a given user?

--Brandon
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
adedCommented:
you want a VBS script, here you are
http://www.bellamyjc.net/download/vbs/sessions.vbs
0
 
AbyzmalAuthor Commented:
I have been playing around with that script a bit. The automatic domain lookup fails, but since I am only using it on one domain I hardcoded it in. Now when I try it on the localmachine, it replies that there are no active sessions (!). When I try it on a remote machine, it fails on this line:

Set LoginProfiles = GetObject("winmgmts://" & Machine).InstancesOf("Win32_NetworkLoginProfile")

I am not sure how to fix this error. But nonetheless it seems that this script still only gives the username logged on at a given machine. What I am looking for is the reverse; a way to find the current computer given a username.
0
 
adedCommented:
ok sorry wrong way
but I don't see how not to poll machines
a simple solution withe polling is a so simply
 NET SESSION \\COMPUTERNAME

logically you know all the machines of your network, so with a batch command you can do it
0
 
bcastaldoCommented:
oh boy, here goes, write it out in a script or do it out, but if this doesnt satisfy you then i dont know, 'net view > people.txt' open file do a find/replace, find '\\' replace with 'nbtstat -a ' boom. save change 'people.txt' to 'people.bat'. run it in a prompt 'people.bat > computer.txt' and do a find on the user name within that file and walla you find the computer name by user.
0
 
AbyzmalAuthor Commented:
Yes, that is a decent solution. The problem is that it connects to every machine on the network, and when you have a few hundred workstations on one network, well... Anyway, I am sure that Micro$oft's netsend uses some other way, I just dunno what it is. If no one else can provide a better solution, then I suppose I'll take that as the answer. Thanks.

--Brandon
0
 
AVSECCommented:
If you have WINS running then you can query it using WINSCL (from NT/2k reskit) to find out the computer name that a user last logged into. I wrote a vbscript ages ago that used WshShell.exec to run WINSCL, get the output, and extract the info I wanted (the computer name the user last logged in to).
0
 
spae0022Commented:
You can use ADNM at http://www.logicdevelopment.net  It has a nice GUI and you can export the results too.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now