|

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.

 

Get new posts by email

One email when a new post goes up. Nothing else.

I only use your address to send new posts, and every email has an unsubscribe link. See the privacy policy.

ShareLinkedInXEmail
Kees Baggerman

Kees Baggerman

Senior Technical Director at Nutanix · NVIDIA Enterprise Platform Advisor · Former Citrix CTP · 15+ years in EUC

Kees Baggerman is Senior Technical Director, Performance & Solutions Engineering R&D at Nutanix, where he leads a global team responsible for defining how enterprise applications are delivered on the Nutanix platform. An NVIDIA Enterprise Platform Advisor since 2017 and a former Citrix Technology Professional, he has spent 15+ years driving EUC strategy and technical direction across architecture, product, and customer success. He has been writing here since 2011, sharing what he learns at the intersection of platform engineering and enterprise IT.

2 Comments

  1. I used this script on a Windows Server 2012 server, but get the error:

    Line: 24
    Char: 5
    Error: OVerflow ‘CCur’
    Code: 800A0006
    Source: Microsoft VBScript runtime error

    Any ideas?

    1. I’ve no current ideas, didn’t test this script against WS2012? Maybe you should go for PoSH (or use the Windows Shell)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.