'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Ithicos Solutions - September 2008 - http://www.ithicos.com ' This script is provided by Ithicos Solutions LLC with no support or warranties. ' This script is designed to be called from a logon script. It checks 2 of the user's attributes: ' If telephoneNumber attribute has 3 or fewer characters, it displays a pop-up message and launches the specified URL ' If the date in extensionAttribute11 is older than 4 months, it displays a pop-up message and launches the specified URL ' Successful use of this script depends on a few things: ' You must enable auditing in the Directory Update AppSettings.XML file and use extensionAttribute11 ' Directory Update must be configured to use Integrated Windows Authentication ' Clients must support Integrated Windows Authentication ' Change the Directory Update "Log Off" button to close the window (in the AppSettings.XML file) ' ' The script takes 2 parameters - the user's name and the URL that you want to launch (the path to Directory Update) ' Here is an example of how to run the script from a batch file or a logon script: ' cscript CheckDirectory.VBS %username% "http://yourservername.yourdomain.com/directoryupdate" ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' '--- PARSE COMMAND LINE ARGS ---------------------------------------------------------------------------------------- ' Check to make sure that 2 arguments/parameters were passed to the script. If not, display a help message. If WScript.Arguments.Count <> 2 Then Wscript.Echo "Usage: cscript " & Wscript.ScriptName & " " Wscript.Echo " e.g. " & Wscript.ScriptName & " UserName ""http://directoryupdate.yourdomain.com/DirectoryUpdate/""" Wscript.Quit End If Dim argUsername, argURL argUsername= WScript.Arguments.Item(0) argURL = WScript.Arguments.Item(1) '--- READ USER ATTRIBUTES -------------------------------------------------------------------------------------------- ' Connect to the Active Directory and read the user's first name, phone number, and extensionAttribute11. Dim adsinfo,nw, telephoneNumber, extensionAttribute1, givenName Set adsinfo = CreateObject("adsysteminfo") Set oUser = GetObject("LDAP://" & adsinfo.UserName) telephoneNumber=oUser.telephoneNumber : extensionAttribute11=oUser.extensionAttribute11 : givenName = oUser.givenName '--- PERFORM THE CHECKING LOGIC AND ACTIONS IF NECESSARY ------------------------------------------------------------- ' The doProcessing subrouting takes 5 parameters. The value of telephoneNumber, the value of exntensionAttribute11, ' the minimum telephone number length, and the number of months old that the data can be. doProcessing telephoneNumber, extensionAttribute11, 3, 4 '--- FUNCTIONS AND SUBROUTINES --------------------------------------------------------------------------------------- Sub doProcessing(telephoneNumber, extensionAttribute11, minTelLength, monthsToReVerify) ' Convert the data from the format that Directory Update stores it in (YYYY-MM-DDThh:mm:ss) to MM/DD/YYYY format On Error Resume Next dim dt 'Convert extAttrib11 from format YYYY-MM-DDThh:mm:ss to MM/DD/YYYY hh:mm:ss ' dt = DateValue(mid(extensionAttribute11, 6, 2) & "/" & mid(extensionAttribute11, 9, 2) & "/" & mid(extensionAttribute11, 1, 4) & " " & mid(extensionAttribute11, 8)) dt=DateValue(Mid(extensionAttribute11,1,10)) If err.Number <> 0 Then 'Not a valid date dt = "" End If On Error Goto 0 ' If the phone number is not set or is not the minimum length, run Directory Update If len(telephoneNumber) < minTelLength Then 'Wscript.Echo "Phone number not set! Start Directory Update!" openIE argURL alertUserEnterDetails ElseIf dt <> "" Then monthsSinceLastUpdate = datediff("m", dt, date) If monthsSinceLastUpdate >= monthsToReVerify Then openIE argURL alertUserCheckDetails monthsSinceLastUpdate End If Else 'Phone number but no date openIE argURL alertUserCheckDetails 0 End If End Sub ' Date check popup. Sub alertUserCheckDetails(monthsAgo) Dim msg if monthsAgo > 0 Then msg = msg & "It has been " & monthsAgo & " months since you updated your details. " End If msg = msg & "Please use Directory Update to verify the accuracy of your contact details then click the Update button to save them." & _ vbcrlf & vbcrlf & "Respectfully," & vbcrlf & "Your IT Department" MsgBox msg End Sub Sub alertUserEnterDetails MsgBox "Please use Directory Update to provide an Office phone number." & _ vbcrlf & vbcrlf & "Respectfully," & vbcrlf & "Your IT Department" End Sub ' Define the Internet Explorer window size and location Sub openIE(url) Dim ie Set ie = CreateObject("internetexplorer.application") ie.Navigate url ie.Visible=True ie.Width=900 : ie.Height=800 : ie.Top=0 : ie.Left=0 'Size and position ie.AddressBar=false : ie.MenuBar=false : ie.ToolBar=false : ie.StatusBar=false 'Hide menus/toolbars End Sub