This works on my own domain from a Win2k or NT box:
use Win32::OLE;
use Win32::OLE::Variant;
use Win32::OLE::NLS qw(:LOCALE :DATE);
my $domain = Win32::OLE->GetObject("WinNT://IRM-NT");
foreach my $object (in $domain) {
if ($object->{Class} eq 'User') {
my $last_login;
if ($object->{LastLogin}) {
$last_login = $object->{LastLogin}->Date(DATE_LONGDATE)
}
else {
$last_login = "Unknown";
}
print $object->{Name} . "=" . $last_login . "\n"
}
}
Just a thought...
jpt
-----Original Message-----
From: Leon [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 12:35 PM
To: Robert-Jan Mora
Cc: perl; win32; Yahoo Beginner Perl
Subject: Re: Last Logon of ALL users in the domain
Hi Robert,
Unfortunately after examining this script it works via passing a username to
it. I can do this with adminmisc. I need to check ALL users in the domain.
Here is a snippet of the code and what it appears to do:
$username = $ARGV[0];
Grab the username from ARGV
I appreciate the attempt though,
Leon
Robert-Jan Mora <[EMAIL PROTECTED]> wrote:
Hello Leon,
Check the site www.roth.net <http://www.roth.net/> and look for examples.
He has a script which is called lastlogon.pl.
Leon wrote:
Hi guys (and ladies!),
I am trying to write a script to find out the last logon of all users in a
domain. I see that with adminmisc I can query a users last logon but this
has to be done on every domain controller. That's fine cause I know that I
can use netadmin and lanman to get a list of all domain controllers in the
domain. My questions is how can I query on all users in the domain?
_____
Do you Yahoo!?
Free online <http://us.rd.yahoo.com/mail_us/tag/*http://calendar.yahoo.com>
calendar with sync to Outlook(TM).
_____
Do you Yahoo!?
Free online <http://us.rd.yahoo.com/mail_us/tag/*http://calendar.yahoo.com>
calendar with sync to Outlook(TM).