' Integer8Date2.vbs ' VBScript program demonstrating an alternative method to convert ' an Integer8 attribute, such as pwdLastSet, to a date value. The ' Integer8Date2 function uses the utility w32tm.exe. ' ' ---------------------------------------------------------------------- ' Copyright (c) 2007 Richard L. Mueller ' Hilltop Lab web site - http://www.rlmueller.net ' Version 1.0 - January 22, 2007 ' ' You have a royalty-free right to use, modify, reproduce, and ' distribute this script file in any way you find useful, provided that ' you agree that the copyright owner above has no warranty, obligations, ' or liability for such use. Option Explicit Dim objUser, objPwdLastSet ' Bind to user object. Set objUser = GetObject("LDAP://cn=TestUser,ou=Sales,dc=MyDomain,dc=com") ' Retrieve pwdLastSet using IADsLargeInteger interface. Set objPwdLastSet = objUser.Get("pwdLastSet") ' Convert the Integer8 value to a date and display. Wscript.Echo "PwdLastSet = " & Integer8Date2(objPwdLastSet) Function Integer8Date2(ByVal objDate) ' Function to convert Integer8 (64-bit) value to a date and time ' in the local time zone. Dim objShell, strCmd, lngValue, objExec, arrWork, strValue Dim lngHigh, lngLow lngHigh = objDate.HighPart lngLow = objdate.LowPart ' Account for error in IADsLargeInteger property methods. If lngLow < 0 Then lngHigh = lngHigh + 1 End If lngValue = (lngHigh) * (2 ^ 32) + lngLow strValue = FormatNumber(lngValue, 0, 0, 0, 0) Set objShell = CreateObject("Wscript.Shell") strCmd = "w32tm.exe /ntte " & strValue Set objExec = objShell.Exec(strCmd) Do While objExec.Status = 0 Wscript.Sleep 100 Loop arrWork = Split(objExec.StdOut.Read(60)) Integer8Date2 = arrWork(3) & " " & arrWork(4) End Function