Link to home
Start Free TrialLog in
Avatar of simpat1zq
simpat1zq

asked on

Find name of computer a user last logged onto

Is there an active directory(or sms) script that will tell me the name of the computer that a user logged onto last, or is currently logged into?

thx.
Avatar of Lazarus
Lazarus
Flag of United States of America image

SMS will also give you the ability to find a user.
Also you can use  the Resource Kit's 'cconnect' tool. Look for it in the 'apps' directory of your Resource Kit CD. There's a Word doc that explains it. This takes a little doing to set up
Avatar of simpat1zq
simpat1zq

ASKER

That tool would take about an hour to run. I need this to avoid having to ask the user to look up the computer name.
Does SMS have a resource kit? Can I download the cconnect tool?
OK, I see that that tool is used in server 2000, but I guess it's not available in 2003. Can I use that tool on a 2003 domain just to see what computer the user is logged into?
Avatar of Steve Knight
Couple of possibilites:

If you have WINS still then the username will be registered in WINS against the IP address - check a query out in the WINS admin tool.

Once you have an Ip then NBTSTAT -A ipaddress will show you the names registered on that computer at the moment which will include the username, domain name, computer name etc.

Doesn't help once users are already logged in but good for logging, I actually run a script from login script which goes away and create a directory for each day, os, user, and computer appending a text file for each -- it goes something like this and just needs a hidden share that users have write rights to.  This is an Auto-It file that compiles to an EXE that can be run from a login script but not too difficult as a batch file either:

;
; AutoIt Version: 2.x
; Language:       English
; Platform:       Win9x/NT
; Author:         Steve Knight (sk@dragon-it.co.uk)
; Date:           14-2-2002


RegRead,CompName,REG_SZ,HKEY_LOCAL_MACHINE,System\\CurrentControlSet\\control\\ComputerName\\ComputerName,ComputerName

  FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\USER\\%username%.txt

  FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\PC\\%compname%.txt

  FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\PC\\%A_OSVERSION%.txt

  FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\PC\\%A_YEAR%-%A_MON%.txt

You end up with a file for each user, computer, month, and OS saying when they have logged on and from what computer and OS.

Yes you can use that tool in 2003 server as well

This is the MS KB on it:
http://support.microsoft.com/Default.aspx?kbid=237282

But I have found a newer tool from MS that takes CCconects place:
Look for a tool called LimitLogon.  It is the new Microsoft replacement tool for cconnect to limit concurrent connections/logons.

http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/limitlogin.exe

Another choice:
1) The UserLock product in the link below is an option:
http://www.softwareshelf.com/products/display.asp?p=42


Last two should missed a bit in the cut & paste:

 FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\OS\\%A_OSVERSION%.txt

  FileAppend, %A_YEAR%-%A_MON%-%A_MDAY% %A_HOUR%:%A_MIN%:%A_SEC% - %A_OSVERSION% - %COMPNAME% - %USERNAME%\n, \\\\server\\share$\\info\\DATE\\%A_YEAR%-%A_MON%.txt
ACK!! never mind my last 2 post. It went into the wrong Question.. and has to do with limit logins...Sorry
if the user has a drive mapped or network filesystem open to some server, you can look at the 'shares' control on the server and see the username and the computer name those resources are access from/by.

Cheers.
 
The thing is that I really want to get the name via a script. I just thought it might be possible using sms somehow to get it. I want it from a script so that I can merge it with another script which needs the computer name a user is connected to.
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
nice, i think I'll try that one.
Yup, that's the one I'm going with. So far i've got a vbscript that creates a file on the share named %username% with %comptername% in it. Now I can use my other scripts to read from those files.

In case any of you were wondering, I'm doing this so that I can connect to someone's computer using SMS remote tools, simply by entering the user's name. If anyone needs these scripts(when I'm done) just ask, I'll post them here.

Thank you.
Nice one, thanks for the points :-)

When you append to the file (use >> if you are using an echo redirection like above) you end up with a nice little audit history too... and you can just read the last line with your script to get the last computer ... or even get clever and offer a list of their last couple by showing the last 5 lines of the file in a dialog for the user to choose before parsing the computername out...

I've found SMS remote a bit of a pain -, at one place it would not work from the commandline with a netbios computername so I wrote scripts to resolve those to IP address and pass that.  Have you tried just running remote.exe with a paramater 3 then the username... vaguely possible it might work?

Steve
Right now I've got an SMS remote tools script that asks for a computername, and then it resolves the IP, and connects using the IP. I found that script off of google, and it just works, no modification necessary. What I'm going to do is modify that script so it makes use of this username thing.

What you said got me thinking about maybe making a logoff script that removes the computer name when they logoff. That way the file would only have a list of computers that they are logged into. But that list might get messy to do to computer crashes and stuff. Maybe I could put in a time/date after the computer name, and run clean up using the login script.

I probably won't do that since most people only log into 1 computer at a time. But I doubt it would be incredibly hard to do.
And I just checked the "remote 3" thing. The 3 just means that it will use the netbios name of the computer. The script I had found finds the IP on it's own and uses "remote 2". But neither can use the username.
Fair enough, I've always resolved the IP and used "remote 2" too... post your script here when done if poss.

Steve
I will. If I don't this week(let's say by wednesday), could you just post here again, so I get an email reminding me to. I tend to forget stuff like this.
I stumbled on this post looking for a different answer, however, this sounds like something that would help me out a bit..I've all but given up on SMS.
I would love to take a look at those scripts if you wouldn't mind...
I'm sorry. I did all that at my last job. I'm 99% sure that the work I did on this is gone. I left when I was just finishing this thing up, and never got it done. Didn't take it with me either, even though I probably should have.
much easier wa .. if you are using domain ofcourse is:
 
filter the security log on the DC for the user name  ;)
 
enjoy
Please contact me on email address in profile, or post a new related Q and let me know the Q number and will have a dig around, pretty sure I've got these old scripts still, and in any case can soon come up with some modern alternatives that work better,
Thanks dragon for the offer ... I appreciate it very much .. I just posted a new solution as i wehere digging for the same problem. I am a consultant myself and i would behappy to exchange solutions or solve them any time.... .