REM put date into name of output and temp files?
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim i, fso, fpr, fpw, filecontents, DN, array, logondate
Set fso = CreateObject("Scripting.FileSystemObject")
Set fpr = fso.OpenTextFile("c:\audit-temp.txt", ForReading)
Set fso = CreateObject("Scripting.FileSystemObject")
set fpw = fso.CreateTextFile("c:\audit-output.htm",True)
filecontents = fpr.ReadLine
fpw.writeline("<html>")
fpw.writeline("<title>" & Date & " " & filecontents & "</title>")
fpw.writeline(Date & " " & filecontents )
fpw.writeline("<table>")
array = split( filecontents, ",")
fpw.writeline("<tr><bold>")
fpw.writeline("<td>LastLogonDate</td>")
for each i in array
fpw.writeline("<td>" & i & "</td>")
next
fpw.writeline("</bold></tr>")
do while (fpr.AtEndofStream <> true)
filecontents = fpr.ReadLine
fpw.writeline("<tr>")
DN = split(filecontents,"""") 'find the DN (enclosed in "")
array = split(DN(2), ",") 'leftover string split by ,
logondate = array(3) / (60 * 10000000)
logondate = logondate / 1440
logondate = logondate + #1/1/1601#
'Wscript.Echo "Last logon time: " & logondate + #1/1/1601#
fpw.writeline("<td>" & logondate & "</td>")
fpw.writeline("<td>" & DN(1) & "</td>") 'put DN column in the table
for i = (lbound(array)+1) to ubound(array) 'skip the first empty pre ,
fpw.writeline("<td>" & array(i) & "</td>") 'put a column in the table
next
fpw.writeline("</tr>")
loop
fpw.writeline("</table></html>")
fpr.close
fpw.close
REM intLastLogonTime = 128369361417343750
REM lastlogontimestamp administrator 15oct07?!?!?!
REM intLastLogonTime = 128377034514062500 REM lastlogon administrator 24oct07 (better!)
REM intLastLogonTime = intLastLogonTime / (60 * 10000000) REM 60 secs * 10,000,000 nanosecs per sec
REM intLastLogonTime = intLastLogonTime / 1440 REM 1440 mins per 24hr day
REM Wscript.Echo "Last logon time: " & intLastLogonTime + #1/1/1601#