Title: RE: Password Expire

Hi - this script will run through your domain (modify as needed), and send an email if the user's password is going to expire in <7 days. 

You'll need to change the following variables to match your environment:
my $domain = 'YOUR NT DOMAIN';
my $mailserver = 'YOUR SMTP SERVER';
my $mailfrom = 'your name';
my $maildomain = 'your mail domain';
my $notifydays = 7;

(yes, I got this script from some where else; don't recall where...)

I've got an AT job  set up to run this every day; it works nicely.

Please read thru the script before asking questions...

-----Original Message-----
From: Veeraraju_Mareddi [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 04, 2001 10:09 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Password Expire


Dear Team,

How do we detect password expire for an account using Win32::Lanman or Win32::AdminMisc.

With Win32::Lanman::Netgetuserattributes(),We  get all User Attributes, But How to detect password Expire. I think password Expire is different from Password Age. IS it right??

Please help if any of you can..

Thanx and Regards
Rajuveera
**************************************************************************
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

**************************************************************************
_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

 

use strict;
use Net::SMTP;
use Win32::Lanman;

my (%info, @exppwd, @users, $server, $user);

# Begin user mod

my $domain = 'YOUR NT DOMAIN';
my $mailserver = 'YOUR MAIL SERVER';
my $mailfrom = 'your name';
my $maildomain = 'your mail domain';
my $notifydays = 7;

# End user mod

die "Unable to locate domain controller for the $domain domain\n" unless
Win32::Lanman::NetGetDCName ('', $domain, \$server);
my ($maxage) = $info{'max_passwd_age'} if
(Win32::Lanman::NetUserModalsGet($server, \%info));
die "No domain policy set for maximum password age\n" unless $maxage;

if (Win32::Lanman::NetGroupGetUsers ($server, 'Domain Users', \@users)) {

foreach $user (@users) {

if (Win32::Lanman::NetUserGetInfo ($server, $user->{'name'},
\%info)) {

next if $info{'flags'} & UF_DONT_EXPIRE_PASSWD ||
$info{'flags'} & UF_ACCOUNTDISABLE
||
$info{'flags'} &
UF_WORKSTATION_TRUST_ACCOUNT ||
$info{'flags'} &
UF_SERVER_TRUST_ACCOUNT ||
$info{'flags'} &
UF_INTERDOMAIN_TRUST_ACCOUNT;

#print "maxage = $maxage\n";
my ($age) = $info{'password_age'};

#print "age= $age\n";
my ($days) = int (($maxage - $age) / 86400);

#print "days =$days\n";
if ($days <= $notifydays) {

if (my $smtp = Net::SMTP->new($mailserver))
{


$smtp->mail("$mailfrom\@$maildomain");

$smtp->to("$user->{'name'}\@$maildomain");
$smtp->to("dpollack\@$maildomain");
$smtp->data();
#$smtp->datasend("To:dpollack\@$maildomain\n");
$smtp->datasend("To:$user->{'name'}\@$maildomain\n");
$smtp->datasend("From:$mailfrom\@$maildomain\n");
$smtp->datasend("Subject: Password Change Reminder\n");
$smtp->datasend("Date:".(gmtime)."\n");
$smtp->datasend("\n");
$smtp->datasend('Your DOMAIN_NYC password is going to expire in less than 7 days.

Please change it immediately.

Instructions on changing your password may be found on the desktop section of 
http://haven.about.com.You may also dial 204-1440 for assistance.

These annoying emails will stop once you change it....Thanks....');
$smtp->dataend();
$smtp->quit;

# for future use - email list of users to admin by sending the list via smtp
#push(@exppwd,$user->{'name'},$days);
#foreach  (@exppwd) { 
#       print "$a\n";
#       }

#open (OUT, ">>pwdlog.\date");
print "$user->{'name'},$days\n";
#close (OUT);


} else {

die "Unable to send mail to
$user->{'name'}\n";

}

}

} else {

die "Unable to read information for
$user->{'name'}\n";

}

}

}


Reply via email to