We have a policy where all accounts (user, etc.) expire in X days..
I wanted to create a notification script to notify when the account is due to expire.
Comments, etc. are welcome.
code:
BREAK ON
CLS
; -- Ref. http://kixtart.org/board/Forum2/HTML/000133.html for date routine
IF Left(@kix,1) < 4
?"This script requires Kixtart 4.x"
SLEEP 2
EXIT
ELSE
$ldomain = @domain
$lstrusername = "servicesql"
$mailhost = "smtp.server.com"
$adminrecpt = "recipient@@server.com"
$userobj = GetObject("WinNT://$LDomain/$lstrUserName")
;$UserObj = GetObject("WinNT://" + $DomainString + "/" + $lstrUserName)
$pwexpire = $userobj.passwordexpirationdate
$dtcalc = $pwexpire = @date
?"UserAuthor: " + $userobj.name
?"UserPasswordExpires: " + $pwexpire
$tt = $pwexpire
$pwdate = substr($tt,1,10)
$pwyear = val(substr($tt,1,4))
$pwmonth = val(substr($tt,6,2))
$pwdate = val(substr($tt,9,2))
$nowyear = @year
$nowmonth = @monthno
$nowdate = @mdayno
IF $pwyear <> $nowyear
$nowmonth = $nowmonth + (12 * ($nowyear - $pwyear))
ENDIF
IF $pwmonth <> $nowmonth
$nowdate = $nowdate + 30
ENDIF
?$nowdate - $pwdate
IF ($nowdate - $pwdate) <= 2
? "Password Change required within 2 days, please change"
SHELL 'postie.exe -host:$MailHost -to:$AdminRecpt -from:"ServiceAccountChg" -s:"Password Change" -msg:"The service account: $lstrUserName needs to be changed."'
ELSE
? "Password older than 2 Days, no action is needed"
ENDIF
ENDIF
Cheers!
- Kent
[ 30 May 2002, 19:05: Message edited by: kdyer ]