Bashar Badr wrote:
> Hi,
> is there a script to check the password age for the user and
> send pop-up message to him before his passwordget expired.
> for example: i want a pop-up message to come to any user before
> 2 days from his passoed expire date.
Hi
Assuming AD domain:
How Long Until My Password Expires?
http://msdn.microsoft.com/library/en...ng09102002.asp
Or using the PasswordLastChanged property:
'--------------------8<----------------------
Const SEC_IN_DAY = 86400
Const ADS_UF_PASSWD_CANT_CHANGE = &H40
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
' Specify how many days before the dialog box will be shown
iExpireDayBeforePasswordExpireDialog = 2
Set oNetwork = CreateObject("Wscript.Network")
Set oADsSysInfo = CreateObject("ADSystemInfo")
sNetBIOSDomain = oNetwork.UserDomain
Set oDomainNT = GetObject("WinNT://" & sNetBIOSDomain)
'Get MaxPasswordAge from Active Directory
iMaxPwdAge = oDomainNT.Get("MaxPasswordAge")
' Retrieve password information for current user
sADsUser = oADsSysInfo.UserName
Set oUserLDAP = GetObject("LDAP://" & sADsUser)
lngFlag = oUserLDAP.Get("userAccountControl")
sPasswdLastChange = oUserLDAP.PasswordLastChanged
blnPwdExpire = True
If (lngFlag And ADS_UF_PASSWD_CANT_CHANGE) <> 0 Then
blnPwdExpire = False
End If
If (lngFlag And ADS_UF_DONT_EXPIRE_PASSWD) <> 0 Then
blnPwdExpire = False
End If
If blnPwdExpire = True Then
iMaxPasswdAgeValue = iMaxPwdAge / SEC_IN_DAY
'Calculate days to password expires
iDaysToPasswordExpires = Int((sPasswdLastChange + iMaxPasswdAgeValue) - Now)
If iDaysToPasswordExpires =< iExpireDayBeforePasswordExpireDialog Then
sInfoMessage = "Your Windows/Active Directory password will expire in " _
& iDaysToPasswordExpires & " day(s)."
'Display messagebox
MsgBox sInfoMessage, vbSystemModal+vbInformation, "Password Expire Check"
End If
End If
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx