Page 2 of 2 <12
Topic Options
#67090 - 2002-06-18 05:35 AM Re: need method of detemining username of remotely logged on user.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Radimus, I'm trying to use your code listed above to learn more about WMI. At this time I am having difficulty getting it to return a username of a logged on user to a W2K terminal server session on my W2K standalone server. Is this approach limited in its usage?

I copied your code and replace the server name in the function call:
WMIQuery("username","Win32_ComputerSystem","bullpup")

Although I have a current Terminal session to Bullpup nothing is returned. Can you shed some light on this?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67091 - 2002-06-18 02:14 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
terminal services may 'alter' the session information... as this method returns the user logged onto the local machine.

terminal services may be able to wmi'd in a different method... dunno, I don't have one to test against.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#67092 - 2002-06-18 03:18 PM Re: need method of detemining username of remotely logged on user.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Thanks for the reply. I am now fighting other problems.
quote:
Script error : unknown command !
$objEnumerator = $SystemSet.ExecQuery($strQuery)

The code works against the local computer but errors when working against other Win2K Pro clients. This is rather frustrating but might be a result of our environment. Still experimenting.

[ 18 June 2002, 15:19: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67093 - 2002-06-18 03:32 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
are you using the new version of wmiquery??
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#67094 - 2002-06-18 04:04 PM Re: need method of detemining username of remotely logged on user.
ylekiot Offline
Fresh Scripter

Registered: 2002-06-18
Posts: 8
What about nbtstat -a (computername or ip address)?

Look for the <03> value

Top
#67095 - 2002-06-18 04:07 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
that was mentions before, but the problem is that that value can be cached for a time...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#67096 - 2002-06-18 05:10 PM Re: need method of detemining username of remotely logged on user.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Yes "nbtstat -a" works and I am using the WMIquery defined in this thread.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67097 - 2002-06-18 09:38 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
have you tried it against a normal desktop?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#67098 - 2002-06-18 09:48 PM Re: need method of detemining username of remotely logged on user.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The last errors I noted in the thread included a normal W2K Pro laptop in a docking station and a W2K server with the owner logged onto the desktop.

Script error : unknown command !
$objEnumerator = $SystemSet.ExecQuery($strQuery)

Specifying my own desktop produces the expected result. I just don't understand why the script dies.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67099 - 2002-06-18 09:53 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
do you have permissions on the laptop?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#67100 - 2002-06-18 10:09 PM Re: need method of detemining username of remotely logged on user.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Just got done testing that. I was in the Administrators group and the failure occurred.

Since it works on my computer, I will just to continue investigating in a methodic manner.

Is this the latest version of the UDF that is in this thread?

Do you know the minimum required level of access that is required to use WMI remotely?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67101 - 2002-06-18 10:22 PM Re: need method of detemining username of remotely logged on user.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I updated the UDF and this thread with the same cut'n paste. only 1 version with the optional $computer parameter

Some queries require admin and some not... I never investigated beyond that as eveyone is local admin on their own PC.

Was the user on the PC local admin??

[ 18 June 2002, 22:22: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 2 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 544 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.127 seconds in which 0.102 seconds were spent on a total of 12 queries. Zlib compression enabled.

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