Page 1 of 2 12>
Topic Options
#62892 - 2002-02-07 12:37 AM Where is user JDOE logged in at?
Kdyer Offline
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 ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62893 - 2002-02-07 01:14 AM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Kent,
I'm trying to understand where you're going with this. Seems you answered your own question. Very similar to the LastLogDate() UDF we worked on. You are correct, that every DC needs to be queried.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62894 - 2002-02-07 01:52 AM Re: Where is user JDOE logged in at?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Les,

Like Emerial Agasse (sp?) always says,

"I want to take this up another notch!"

I want to know what machine they are logging into without having to trawl through some database or log file. Or not knowing which BDC they are logging into.

Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62895 - 2002-02-07 04:02 AM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Kent,
I'm a bit slow but it's starting to sink in a bit. Not at a DC so can't test your batch.

I have two methods of figuring out where someone is logged in. The first is to look in the WINS db. Fine if the user is only logged on to one PC. The other is to NET SEND a message to the user to call me. Yeah, I know, low tech.

Perhaps you could streamline your log format so that you don't need to reverse search it. If you set it up in an ini format with the username as the key and WriteProfileString("file name", "section", "@UserID", "@WkSta") the log details, it would be a one-liner retrieve.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62896 - 2002-02-07 06:38 AM Re: Where is user JDOE logged in at?
Radimus Moderator Offline
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
PsLoggedOn

I 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

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#62897 - 2002-02-08 09:01 AM Re: Where is user JDOE logged in at?
Netsuper Offline
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
#62898 - 2002-02-08 09:13 AM Re: Where is user JDOE logged in at?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kdyer,
I can't fully follow you...
you have script for quering from bdc the logon time and wksta.
why can't you query all servers having logon service running...
that one I've used.
then just compare, which is the newist info.
_________________________
!

download KiXnet

Top
#62899 - 2002-02-08 03:50 PM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jooel,
That'd tell you when but not where.

The PSLoggedOn util is OK until you hit a Linux box and then it really dogs.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62900 - 2002-02-08 04:04 PM Re: Where is user JDOE logged in at?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Guys....

I am already writing to a log. We have introduced a secondary domain. It would be cool to not only query the DC you login to, but capture the machine you login at..

It seems like I am asking the impossible. I am able to get the Last Logged in time, etc. However, I want to get the machine name. Even if I setup to start looping though our 30+ DCs, it would take a long time to do this.

Sorry...

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62901 - 2002-02-08 04:23 PM Re: Where is user JDOE logged in at?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm coming in late on this so maybe I'm missing something...

I keep a hidden "login.log" in the root of each users home share which records their workstation (@WKSTA), login server (@LSERVER), Citrix client name, thick/thin client type, date and times as well as all the debug information from all the bits of the login scripts that are executed.

As an administrator I just check the log file in the users' home directory for a history of their logins.

Top
#62902 - 2002-02-08 04:41 PM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Kent,
Nothing to be sorry about. I think I know what you want; to query AD for the WS name the user logged on from/to. Don't think it's in there, or if it is don't know where.

The other suggestions are based on your comment RE: parsing a flat log file.

Sorry we're no closer to your goal, but at least there's some good ideas floating around and at least this thread gets bumped back to the top.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62903 - 2002-02-08 04:47 PM Re: Where is user JDOE logged in at?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
I know I am a little late, but I have been using a program called NTName to find what computer a person is on for a control program I made. You can find ntname at NTName.

krabourn

[ 08 February 2002: Message edited by: krabourn ]

_________________________
Kelly

Top
#62904 - 2002-02-08 05:04 PM Re: Where is user JDOE logged in at?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Krabourn,

You da man..

Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62905 - 2002-02-08 05:27 PM Re: Where is user JDOE logged in at?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
Thanks.

Now all we need is someone to go through the source code and make a COM object out of it. At least I wish I had something like that.

krabourn

_________________________
Kelly

Top
#62906 - 2002-02-08 05:50 PM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well, hate to burst anyone's bubble, but there are inherent problems with NTName. From what I can gather, it queries WINS for the name, so if you have multiple domains, (I have 58) and the same name exists in another domain, it is likely to return the wrong info. Also, if the user logs on to more than one PC, same prob. This relates back to my second post in this thread.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62907 - 2002-02-08 06:15 PM Re: Where is user JDOE logged in at?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Les,

It may not be elegant or a good way to do this, but with the C code included, we maybe able to parse the information into a logical script.

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62908 - 2002-02-08 06:17 PM Re: Where is user JDOE logged in at?
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
My bubble is not broke. We use it here and it has worked everytime. Lucky, I guess. We have MANY domains, just over 400, here.
_________________________
Kelly

Top
#62909 - 2002-02-08 06:52 PM Re: Where is user JDOE logged in at?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In my case, may be because my WINS/NBT node type is H-Node (0x8). In your case, can't argue with what works.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62910 - 2002-02-08 08:03 PM Re: Where is user JDOE logged in at?
Alex.H Offline
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 database

For 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 Offline
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
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.073 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org