RES Workspace Manager and Change Password dialog
One of our customers noticed that the balloon that pops up when a password is about to expire isn’t displayed properly while using RES Workspace Manager. I send them an old powershell script that checks Active Directory and sends an email when the password expire date is within 14 days.
This was a good start but the script should be able to run on Windows XP and Windows 7 so a powershell script wasn’t the best choice. One of the admins wrote the following script which runs when logging on. It checks for the password expire data and gives a pop up when it’s within 14 days:
'======================================== ' First, get the domain policy. '======================================== Dim oDomain Dim oUser Dim maxPwdAge Dim numDays Dim warningDays warningDays = 14 Set LoginInfo = CreateObject("ADSystemInfo") Set objUser = GetObject("LDAP://" & LoginInfo.UserName & "") strDomainDN = UCase(LoginInfo.DomainDNSName) strUserDN = LoginInfo.UserName Set oDomain = GetObject("LDAP://" & strDomainDN) Set maxPwdAge = oDomain.Get("maxPwdAge") '======================================== ' Calculate the number of days that are ' held in this value. '======================================== numDays = CCur((maxPwdAge.HighPart * 2 ^ 32) + _ maxPwdAge.LowPart) / CCur(-864000000000) 'WScript.Echo "Maximum Password Age: " & numDays '======================================== ' Determine the last time that the user ' changed his or her password. '======================================== Set oUser = GetObject("LDAP://" & strUserDN) '======================================== ' Add the number of days to the last time ' the password was set. '======================================== whenPasswordExpires = DateAdd("d", numDays, oUser.PasswordLastChanged) fromDate = Date daysLeft = DateDiff("d",fromDate,whenPasswordExpires) 'WScript.Echo "Password Last Changed: " & oUser.PasswordLastChanged if (daysLeft < warningDays) and (daysLeft > -1) then Msgbox "Uw wachtwoord verloopt over " & daysLeft & " dagen" & " op " & whenPasswordExpires & chr(13) & chr(13) & "Druk na het inloggen op CTRL-ALT-DEL en " & chr(13) & "kies voor 'Wachtwoord wijzigen'", 0, "Wachtwoord waarschuwing!" End if '======================================== ' Clean up. '======================================== Set oUser = Nothing Set maxPwdAge = Nothing Set oDomain = Nothing
In this case I didn’t write the script so I have to thank Niek de Vries for letting me publish this script on my blog.
Thanks! Great solution for a problem we had. You might want to add that this is a VBS script (but maybe its just me that is not yet a scripting wizard).