Page 1 of 2 12>
Topic Options
#32158 - 2002-11-11 01:01 PM Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
I'm putting together a GUI to determine:
  • which machines are in a domain
  • if a user is logged-on on that machine
  • which OS is remotely running
As a start i was looking at the Computer Account Password Age from Chris, but i miss the part listed above. Can anyone help me with this or point me in the right direction. The machines are running W2K Pro SP3 and the person running the GUI has admin privs on the remote machine.

[ 11. November 2002, 13:04: Message edited by: Schuliebug ]
_________________________
Kind regards,

Top
#32159 - 2002-11-11 01:19 PM Re: Determine which user is logged on a remote machine
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, let's try:
Identifying the User Logged on to a Remote Computer
Enumerate Computer Accounts in Active Directory
Identify the Operating System

and to search more, just check the main folder:
Microsoft Technet - Script Center

the scripts are not kix but are so simple that it shouldn't be hard to translate them...

was this the rigth direction?
_________________________
!

download KiXnet

Top
#32160 - 2002-11-11 01:23 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Lonkero,

I just searched to KiXforms forum, not technet [Frown] I get into it right away, thankz [Smile]
_________________________
Kind regards,

Top
#32161 - 2002-11-11 01:59 PM Re: Determine which user is logged on a remote machine
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
See item #2 on my page http://mywebpages.comcast.net/habullock/kix_solutions.htm. Most of the examples that that return the current user are looking for an interactive user. In the case you may be looking for all users currently logged on including services, there is code on my page.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32162 - 2002-11-11 03:12 PM Re: Determine which user is logged on a remote machine
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also the following UDFs:
IdentifyRemoteUser() Identifying the User Logged on to a Remote Computer
LoggedinUsers() - Retrieves a list of users/SIDs currently logged into a computer
_________________________
There are two types of vessels, submarines and targets.

Top
#32163 - 2002-11-11 03:22 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Thankz Howard, but i'm trying to use Lonkero's suggestions [Smile] Fine examples however !! Further, i'm looking at KixoMatic, which generates a part of the script..

I try the following code:
code:
  $objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$objCom.Name+"\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For each $objItem in $colItems
$Item.SubItems(1)=$objItem.UserName
Next

$colItems = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For each $objItem in $colItems
$Item.SubItems(2).Text=$objItem.Caption+' ('+$objItem.Version+')'
Next

When looking at the code, i get error -2147023174 using GetObject and the message that a script error occurs:

code:
Script error: expected expression!
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)



[ 11. November 2002, 16:07: Message edited by: Schuliebug ]
_________________________
Kind regards,

Top
#32164 - 2002-11-11 04:16 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Sealeopard,

When using the code form the links, same happens [Frown] Could it be some rights problem, e.g. could i use someting different from impersonate ?
_________________________
Kind regards,

Top
#32165 - 2002-11-11 04:19 PM Re: Determine which user is logged on a remote machine
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
schulie, what is:
$objCom.Name

where it comes from?
the error is related to the fact that the first line failes to get object.
_________________________
!

download KiXnet

Top
#32166 - 2002-11-11 04:22 PM Re: Determine which user is logged on a remote machine
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
shuliebug,
For a WMI solution you have to make sure all the clients have WMI as well.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#32167 - 2002-11-11 04:34 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Lonkero,

$objCom.Name is the computername. It is enumerated by the script (see previous posts)..

Les,

The clients are all W2K Pro machines..

I'm using KiXtart 4.11 on the client..

[ 11. November 2002, 16:43: Message edited by: Schuliebug ]
_________________________
Kind regards,

Top
#32168 - 2002-11-11 06:24 PM Re: Determine which user is logged on a remote machine
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Are you using an account that has local admin rights? Might be a rights issue.
_________________________
There are two types of vessels, submarines and targets.

Top
#32169 - 2002-11-15 11:23 AM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Sorry for the waiting time: i've been a little sick last few days... [Frown] [Frown]

sealeopard:
I'm member of a domain global group W2PBeheer (dutch) which is member of the workstation's local administrators group. I'm even member of the domain global group Domain Admins, which is also member of the same workstation's local administrators group. I should have enough rights to collect WMI data from the workstation [Confused] ...

I could sent you an example, but even with the KixOMatic script it doesn't work (and according to the M$ site it should) (i 'borrowed' some code from KixOMatic.kix
_________________________
Kind regards,

Top
#32170 - 2002-11-15 11:42 AM Re: Determine which user is logged on a remote machine
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, if the workstation is nt/w9x there might just not be WMI
_________________________
!

download KiXnet

Top
#32171 - 2002-11-16 12:05 AM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Lonkero,

As i already stated: the workstations are W2K SP3.. [Wink]
_________________________
Kind regards,

Top
#32172 - 2002-11-17 09:21 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Lonkero, Sealeopard,

I tested the script towards a W2K server and it works against that well, so somehow i've got a security/rights problem regarding WMI. Maybe the fact that at the end of our handsoff W2K Pro installation, secedit is used to lock-down the workstation has something to do with it. I will test the code with a workstation not locked by secedit, and will post the results here [Wink]
_________________________
Kind regards,

Top
#32173 - 2002-11-18 11:07 AM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Another question regarding same subject: how can i use other credentials than my own instead of ImpersonationLevel=impersonate ??
_________________________
Kind regards,

Top
#32174 - 2002-11-18 11:09 AM Re: Determine which user is logged on a remote machine
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
manually typing or by automation?

did you get any results with that test?
_________________________
!

download KiXnet

Top
#32175 - 2002-11-18 01:28 PM Re: Determine which user is logged on a remote machine
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Lonkero,

I've tested it with machines on the same domain and those can be reached... Only machines in another domain i can't reach [Frown] Should be possible with something like Wbemscripting.SWbemLocator (i'm sure the syntax is wrong, but i don't know what's causing the problem):
code:
$ObjWBemScripting=GetObject("Wbemscripting.SWbemLocator")
; line above returnes error<>0, object not available..

$ObjWBemLocator=$ObjWBemScripting.ConnectServer("$objCom.Name","root\cimv2","$sDomain\SchedAdmin","schedadmin")
; and so line above doesn't work..

$ObjWMIService=GetObject("winmgmts:\\"+$objCom.Name+"\root\cimv2")

I'm also not sure if the last line is correct, because i
_________________________
Kind regards,

Top
#32176 - 2002-11-18 01:36 PM Re: Determine which user is logged on a remote machine
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so what is the code that worked for local domain?
_________________________
!

download KiXnet

Top
#32177 - 2002-11-18 08:06 PM Re: Determine which user is logged on a remote machine
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See ReadEventlog() - Retrieves event from the eventlog for a method to connect to remote computers using specified credentials.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1003 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.074 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