VB Script to show Expiration Date in BGInfo

'========================================
' First, get the domain policy.
'========================================
Dim oDomain
Dim oUser
Dim warningDays
warningDays = 30

Set LoginInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & LoginInfo.UserName & "")
strDomainDN = UCase(LoginInfo.DomainDNSName)
strUserDN = LoginInfo.UserName

Set oDomain = GetObject("LDAP://" & strDomainDN)

'========================================
' Determine the last time that the user
' changed his or her password.
'========================================
Set oUser = GetObject("LDAP://" & strUserDN)
'intUAC = oUser.Get("userAccountControl")

'========================================
' Add the number of days to the last time
' the password was set.
'========================================
whenPasswordExpires = DateAdd("d", 180, oUser.PasswordLastChanged)
daysLeft = DateDiff("d",fromDate,whenPasswordExpires)

Echo("Password Expiration Date :" & FormatDateTime(whenPasswordExpires,2))
If daysLeft < warningDays Then
Echo("Days Left :(" & daysLeft & " Days)")
End IF

'========================================
' Clean up.
'========================================
Set oUser = Nothing
Set oDomain = Nothing

Comments