Solved

Look up logged on user on Win32

Posted on 2002-05-10
8
167 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl script help 5 232
Having a problem with ActiveState Perl on 64-bit Windows 7 3 68
PERL - Find newest folder 12 112
Perl script to delete older files 6 69
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

937 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now