Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding machine names (or IP) of logged in users

Status
Not open for further replies.

krinid

Programmer
Jun 10, 2003
356
0
0
CA
Anyone know a good way/tool to find the machine name (or IP) of logged in users? (Short of asking the users)

Users are running Win XP Pro, and we admins are running either W2K Pro or XP Pro. All users exist in AD, and we have the user's name and network login ID.
 
How are the IP's issued? if DHCP server is running then you should have a list of current leases in there!

Rob
 
Diancecht - if I could get that working, it'd be ideal. Not sure if I'm using it properly, but my connection is refused every time. Is this an internet only tool, or can it be used internally? According to XP doesn't offer a finger service.

TamedTech - they are DHCP, so far as I know; not sure if we have access to that - any commands available to access a list of active DHCP assignments?

A bit of background on the task at hand:
(NOTE: this works with W2K Pro but not XP Pro SP2)
We have a script that does a NET SEND to the client, then does NBTSTAT -c and scans through the output for the user's name and then takes the corresponding hostname. However, under XP, there's two problems:
1) Under Win XP SP2 (that's what we're running), Messenger service is disabled by default (by design)
2) Even after starting the Messenger service, the remote user being messaged doesn't seem to be cached, and hence the results aren't found in the output of NBTSTAT -c

I don't need a result that necessary uses this, but just in case this gives anyone some ideas.
 
If you have a log-in script you could possible add something like the below. We use a .bat file a log-in script and this worked for me.

@ECHO OFF

net use I: \\FILE_SRVR\PC_Stuff /YES

MD C:\_asdf
CD C:\_asdf
echo %USERNAME% >> %COMPUTERNAME%.txt
echo %COMPUTERNAME% on %USERDOMAIN% >> %COMPUTERNAME%.txt
echo %DATE% >> %COMPUTERNAME%.txt
echo %TIME% >> %COMPUTERNAME%.txt
COPY C:\_asdf\%COMPUTERNAME%.txt I:\PC_Info
ATTRIB +H C:\_asdf

This created a folder called "_asdf" on the C:\ drive of the local PC. Then, in that folder, it created a file with the name of the PC "(pcname).txt". Then, in that file it created lines of text that showed user, computer name and domain, date they are logging on and time they are logging on. It then copies the file to the I: drive (which is our file server. Finally, it makes the "_asdf" folder hidden.

You can check all pre-set variables by going to a command prompt and typing in "set".
 
Sorry. I forgot to add the part about putting the IP in the text file. Here's the whole thing:

@ECHO OFF

net use I: \\FILE_SRVR\PC_Stuff /YES

MD C:\_asdf
CD C:\_asdf
echo %USERNAME% >> %COMPUTERNAME%.txt
echo %COMPUTERNAME% on %USERDOMAIN% >> %COMPUTERNAME%.txt
echo %DATE% >> %COMPUTERNAME%.txt
echo %TIME% >> %COMPUTERNAME%.txt
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "IP Address"') DO FOR %%B IN (%%A) DO SET FULLIPADDR=%%B
echo %FULLIPADDR% >> %COMPUTERNAME%.txt
COPY C:\_asdf\%COMPUTERNAME%.txt I:\PC_Info
ATTRIB +H C:\_asdf
 
I don't know how to go from user name / account to single computer name. And if one person was using multiple computers, this wouldn't be accurate anyway.

PSExec, running PSLoggedOn, will give you the name of everybody logged on to any computer in the domain / workgroup. You can search the output for the user name.
psexec \\* psloggedon

PSExec and PSLoggedOn are part of PSTools (free) from Sysinternals.

Cheers,

Chuck
Paranoia is not a problem, when it's a normal response from experience.
 
mpnut - That's an idea that would definitely work; I'll keep that in mind. If possible, I'd like to get a system going that doesn't add anything but just uses the info available. There just seems like there should be a quick and easy way to find the information.

cacroll - PSLoggedOn itself seemed to find me logged into many machines; perhaps it's counting share sessions as well. psexec \\* psloggedon got connections refused at each connection attempt. However, both of them look like they would take too long to finish searching through all the PC's in the domain. We don't mind not being able to handle users logged into multiple PC's, provided it's a genuine login and not just a share, as that would be the exception for us.
 
I've come across the tool dsquery, but I haven't been to hone it to get the right result. It may not be able to access user log in information, although it seems to process computer names and user information very quickly.

Does anyone have any experience with dsquery?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top