Solved

Look up logged on user on Win32

Posted on 2002-05-10
8
186 Views
Last Modified: 2010-03-05
Hello,

Is there some way in perl to look up who is logged on to remote machine.  I want to be able to specify a machine and lookup who is logged onto it.  This is on Window NT/2000.

Thanks,

Joe


0
Comment
Question by:jvieira
  • 4
  • 3
8 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7002964
system("net.exe name-of-pdc session");
0
 
LVL 6

Accepted Solution

by:
sstouk earned 100 total points
ID: 7003590
The net session command would not work in Workgroup.

There are tho ways of identifying who is logged in to the LOCAL system:

$name = Win32::AdminMisc::GetLogonName();
Using the AdminMisc module
or
$user = Win32::LoginName();

To do the task, you could create a small script, which creates a file with the current login name of the user.
You can access the file with any remote access and have a look at it.

But if systems are on the domain, the best way is to use the "net session" command as "ahoffmann"  gave you an example of.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7004649
in a workgroup you cannot "logon" to a remote server, just "connect" shares
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jvieira
ID: 7011758
OK,

To clarify something.  The perl program will be running on WindowsNT/2000 but it will be quering machine that are Windows NT/2000/98.  Perl is not installed on all the machine which is why I want to query it remotely.  I don't think the net session program exists on 98.  Win32::LoginName only works on the local machine I want who is logged in on a remote machine.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7011941
install rshd.exe from NT's ResKit. AFAIK it works for 98 too.
Then you can use
   rsh remotehost net.exe session
or for Win98
   rsh remotehost echo %USER%

To find out which OS it is use:
   rsh remotehost echo %OS%
which retuns Windows_NT on NT and nothing on Win98.

Check the commands in a shell (cmd.exe), then it should be simple to use them within perl with system() or backticks (if your perl support backticks on NT)
0
 

Author Comment

by:jvieira
ID: 7011950
That requires me to go to every machine and install the rshd.exe application.  If I'm already at their machine I can just lookup who is logged on.  There must be something either in the registry or something else that I can look at from a remote machine and see who is logged on without ever having to go to the machine or install anything on it.

I can get disk and network info remotely now all I need is user info.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7011973
> There must be something either ..
hmm, laugh or cry ;-) Remeber: it's M$ !!

Think you're clued to M$ proprietary things like SMP, but that requires installation either, IIRC.
0
 

Author Comment

by:jvieira
ID: 7022522
Since the answer is "it can't be done." I'll award the points to sstouk.  His answer does not require using anything but perl even though it won't do it remotely.  

Thanks anyway,

Joe
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question