Find out when your password expires


I didn’t like to get the warning that my password expires 14 days before. I like to wait til the last minute, cuz then I’ll have to change it less often. Thus I’d like to make the warning come up later.


 


Just change this registry value:


 


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\passwordexpirywarning


 


I changed mine from 14 days to 7.


 


I also wanted to know when my password would expire:


 


 


oADs=CREATEOBJECT(“ADSystemInfo”)


?oADs.UserName


oUser=GETOBJECT(“LDAP://”+oADs.UserName)


?oUser.get(“mail”)      && email address


IF BITAND(oUser.get(“userAccountControl”) , 0x10000)>0


      ?”Password doesn’t expire”


ELSE


      oDomain=GETOBJECT(“LDAP://”+oADS.DomainDNSName)


      oAge=oDomain.Get(“maxPwdAge”)


      nMaxAge=ABS(oAge.HighPart * 2^32+oAge.LowPart) /1e7/86400


      ?”Max Password Age=”,nMaxAge


      ?”Password expires: “,oUser.PasswordLastChanged+nMaxAge*86400


ENDIF


 


 


 


 


See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting09102002.asp


 


 


 

Comments (2)

  1. DanaF says:

    I Use following code in my vb.net application:

    Dim oUser = GetObject("WinNT://./" & userName & ",user")

                   MsgBox(oUser.PasswordExpirationDate())