' Days before to alert user QtDiasAviso=7RedirectRdWeb=trueUrlRDWEB="https://monserveur/RDWeb/Pages/fr-FR/password.aspx"Message_alert=""ConstADS_UF_DONT_EXPIRE_PASSWD=&h10000SetoTranslate=CreateObject("NameTranslate")SetoNetwork=CreateObject("WScript.Network")Setwshell=WScript.CreateObject("WScript.Shell")oTranslate.Init3,""oTranslate.Set3,oNetwork.UserDomain&"\"&oNetwork.UserNameSetobjUserLDAP=GetObject_("LDAP://"&oTranslate.Get(1))intCurrentValue=objUserLDAP.Get("userAccountControl")' Check if user account have date to password expires IfnotintCurrentValueandADS_UF_DONT_EXPIRE_PASSWDThen' Determine when password expires and calculate the days ' Instead of PasswordExpirationDate, you can use the accountExpirationDate property, depending on the case SenhaAlt=DateDiff("d",date,objUserLDAP.PasswordExpirationDate)' If password will expire if(SenhaAlt<=QtDiasAviso)thenMessage_alert="Votre mot de passe expire dans "&SenhaAlt&" jour(s) "&vbCrLf&vbCrLf&"Merci de le changer dès que possible"if(RedirectRdWeb=true)thenMessage_alert=Message_alert&vbCrLf&vbCrLf&"Une page intranet va s'ouvrir pour vous permettre le changement"endifMsgBoxMessage_alert,vbExclamation,"Expiration de votre mot de passe"if(RedirectRdWeb=true)thenwshell.RunUrlRDWEBendifendifendif
Customizing the script
line 2 :
QtDiasAviso = 7
Number of days the message begins to appear
line 3 :
RedirectRdWeb = true
True : opens the page defined in the UrlRDWEB variable when the user clicks OK