I've written one that gets a list of all DC's, forks a process for each
one, and then watches for completion of all processes.  It then combs
the reports generated by each, selects the most recent date for each
user, and cleans up the working files.  It still takes a long time as
I'm doing the query against the remote DC's a user at a time using 

 

       if ( Win32::AdminMisc::UserGetMiscAttributes("\\\\$Server",
$User, \%Userinfo))

          {

            

            # Print username, last logon

            print OUT "$User^".$Userinfo{USER_LAST_LOGON}."\n";

 

 

Does anyone know of a speedier way to implement this without invoking a
remote process on the server?  

 

 

Kevin Gould

Sr. I/T Specialist

Gentiva Health Services, Overland Park, KS

913-814-2369

 

-----Original Message-----
From: Rosenstein, Leon [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 1:22 PM
To: '[EMAIL PROTECTED]'; 'Leon'; 'Tillman, James';
'Robert-Jan Mora'
Cc: 'perl'; 'win32'; 'Yahoo Beginner Perl'
Subject: RE: Last Logon of ALL users in the domain

 

Is there way to have it query all domain controllers in the domain?  I
was thinking of modifying it to run the script as a subroutine and use
lanman or netadmin to loop it through all the DC's.  The problem is if
you have more then one DC you wont get accurate results.  It needs to be
run on each one.  I was thinking of having it run as a sub, hit each
one, dump the info into a text file and then use excel to clean it up.
Does anyone know how to implement that easily or think that is the best
way to do it?

 

Thx,

 

Leon

 

-----Original Message-----
From: Tim Dumas [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:00 PM
To: 'Leon'; 'Tillman, James'; 'Robert-Jan Mora'
Cc: 'perl'; 'win32'; 'Yahoo Beginner Perl'
Subject: RE: Last Logon of ALL users in the domain

 

If you want the Time of logon along with the date you can use this
modified version.

 

 

use Win32::OLE;
use Win32::OLE::Variant;
use Win32::OLE::NLS qw(:LOCALE :DATE);
my $domain = Win32::OLE->GetObject("WinNT://DomainHere");
foreach my $object (in $domain)
{
    if ($object->{Class} eq 'User')
    {
        my $last_login;
        if ($object->{LastLogin})
        {
            $last_login_date =
$object->{LastLogin}->Date(DATE_LONGDATE);
            $last_login_time = $object->{LastLogin}->Time();
        }else
        {
            $last_login_date = "Unknown";
            $last_login_time = "Unknown";
        }
        print $object->{Name} .. "=" . $last_login_date . " " .
$last_login_time ."\n";
    }
}

 

Tim Dumas

        -----Original Message-----
        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Leon
        Sent: Thursday, June 12, 2003 12:03 PM
        To: Tillman, James; Robert-Jan Mora
        Cc: perl; win32; Yahoo Beginner Perl
        Subject: RE: Last Logon of ALL users in the domain

        This totally 100 percent worked.

         

        Thank you so much!!!!
        
        "Tillman, James" <[EMAIL PROTECTED]> wrote:

                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

INDEPENDENCE COMMUNITY BANK CONFIDENTIALITY NOTICE: This message 
(and any attachment) is confidential and 
intended for the sole use of the individual or entity to which it is
addressed. If you are 
not the intended recipient, you must not review, retransmit, convert to
hard-copy, 
copy, use or disseminate this email or any of its attachments. If you
received this email 
in error, please notify the sender immediately and delete it. This
notice is automatically 
appended to all Internet email.
 

Reply via email to