#62892 - 2002-02-07 12:37 AM
Where is user JDOE logged in at?
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
We have used the following Batch script to find where a user is logged in at...However, it does appear to have limitations. You have to hit the server where the user logs in at to get results. You cannot run this from a workstation. Pinging Alex.. Pinging Shawn.. It should be doable in ADSI, but we are running in mixed-mode until all of our servers/systems are converted over to 2000. I have created in our Kix script the ability to log the users, but the log gets pretty unwieldy and you have to search in reverse order. I did find the following.. http://cwashington.netreach.net/depo/view.asp?Index=198&ScriptType=vbscript DISCLAIMER - This batch script has been around a while, it is not my original work.
code:
@echo off setlocal if NOT "%1"=="" goto begin :syntax @echo Syntax: WhereUAt UserName1 [UserName2 ... UserNameN] endlocal goto end :begin if "%1"=="" endlocal & goto end set user=%1 set user=%user:"=% shift for /f "Skip=4 Tokens=*" %%i in ('net session') do call arse "%%i" goto begin arse set str=%1 set str=%str:"=% if "%str%"=="The command completed successfully." goto end for /f "Tokens=*" %%i in ('@echo %%str:~23^,20%%') do set substr=%%i? if "%substr%"=="ECHO is on.?" goto end set substr=%substr: =% set substr=%substr: ?=% set substr=%substr:?=% if /i not "%user%"=="%substr%" goto end @echo %str% :end
I was able to munge some this together from some code from http://cwashington.netreach.net
code:
$DCString = "DOMAIN" $User = "kdyer" $DomainObj = GetObject("WinNT://" + $DCString) $DomainObj.filter = array($User)For Each $UserObj In $DomainObj $Name = $UserObj.Name $Description = $UserObj.Description $FullName = $UserObj.FullName $LastLogin = $UserObj.LastLogin $AuthServer = $DCString next
It would be pretty cool to not only have the workstation ID(s) where the user has logged in at, but time(s) they logged in too. Thanks for any insight. - Kent [ 07 February 2002: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#62896 - 2002-02-07 06:38 AM
Re: Where is user JDOE logged in at?
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
LoggedOn freeware locates where a user is logged on or who is logged onto a local or remote computer PsLoggedOnI know it isn't what you are looking for, but you could setup a ini file in a common location using writeprofilestring("\\pdc\share\user.log","ByUser","@userid","@Wksta, @date @time") writeprofilestring("\\pdc\share\user.log","ByComputer","@Wksta","@userid, @date @time") not elegant, but quick and easy
|
|
Top
|
|
|
|
#62897 - 2002-02-08 09:01 AM
Re: Where is user JDOE logged in at?
|
Netsuper
Getting the hang of it
Registered: 2001-05-17
Posts: 64
Loc: Edwards AFB, CA, US
|
We implemented a "last logon" script which created a file on a central location.The filename was something to the effect of: path\User on computername at time.txt the script looked something like this: -------------- $file = @userid + " on " + @wksta + " at " + @time + ".txt" del $file ; this keeps it current $fo = open(1,$file,5) $wl = writeline(1,@logonserver) $fc = close(1) ------------- It created a 1k file and it could be sorted on filename or date in explorer. It wouldn't tell whether they were logged in currently, but it would tell from what last computer they were logged on from. hope this helps? 
_________________________
Scott Hickerson
Network Design Engineer
|
|
Top
|
|
|
|
#62910 - 2002-02-08 08:03 PM
Re: Where is user JDOE logged in at?
|
Alex.H
Seasoned Scripter
Registered: 2001-04-10
Posts: 406
Loc: France
|
Kent, Hope i'm not too late What you are asking about is possible, and would be easier with LDAP, as it's possible to use it through ADO object and so, working as if we have a databaseFor the moment, as i've just drop a look into this, here are what i'm thinking about : ADsearch UDF in UDF section to start. ADsearchpanel sample provided with KiXGUI. get a look to this link (it's completely stand alone) and the user and workstation ADs properties from MSDN (seems the User.LoginWorkstations property will do the job) Also, never forget Dynamic object (we have the session object using WinNT:// which look promising) I'll see this more closer this WE if i can. Let me know if you found something
_________________________
? getobject(Kixtart.org.Signature)
|
|
Top
|
|
|
|
#62911 - 2002-02-11 11:31 PM
Re: Where is user JDOE logged in at?
|
Alex.H
Seasoned Scripter
Registered: 2001-04-10
Posts: 406
Loc: France
|
*bump* Kent ? sorry but no time this we. Did you got something ?
_________________________
? getobject(Kixtart.org.Signature)
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 580 anonymous users online.
|
|
|