Determines the date when a user password will expire.
Const SEC_IN_DAY = 86400Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000Set objUserLDAP = GetObject _("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com")intCurrentValue = objUserLDAP.Get("userAccountControl")If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Thenwscript.echo "The password does not expire."ElsedtmValue = objUserLDAP.PasswordLastChangedWscript.echo "The password was last changed on " & _DateValue(dtmValue) & " at " & TimeValue(dtmValue) & VbCrLf & _"The difference between when the password was last set" & VbCrLf & _"and today is " & int(now - dtmValue) & " days"intTimeInterval = int(now - dtmValue)Set objDomainNT = GetObject("WinNT://fabrikam")intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")If intMaxPwdAge < 0 ThenWScript.Echo "The Maximum Password Age is set to 0 in the " & _"domain. Therefore, the password does not expire."ElseintMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)Wscript.echo "The maximum password age is " & intMaxPwdAge & " days"If intTimeInterval >= intMaxPwdAge ThenWscript.echo "The password has expired."ElseWscript.echo "The password will expire on " & _DateValue(dtmValue + intMaxPwdAge) & " (" & _int((dtmValue + intMaxPwdAge) - now) & " days from today" & ")."End IfEnd IfEnd If
This is a VB Script, this can be used by saving the file in .vbs file