No announcement yet.

VBS script problem

  • Filter
  • Time
  • Show
Clear All
new posts

  • VBS script problem


    Using this script to obtain account login info and populate an Access database. Everything works fine except it refuses to retrieve the LastFailedLogin time info. If I change that to LastLogin like the previous line it will populate the field fine. Any ideas???


    'Access Database Structure (set up database table as follows)
    'Database Author: lastlog.mdb
    'Table Author: LastLog
    'Fields: Author: Type:
    'F1 ID AutoNumber
    'F2 UserName Text:15
    'F3 Description Text:50
    'F4 FullName Text:50
    'F5 LastLogin Date/Time
    'F6 LstFldLogin Date/Time
    'F7 AuthServer Text:20
    'F8 RunDate Date/Time

    Option Explicit
    On Error Resume Next
    Dim FSO, FSI, f, DCString, DomainObj, ObjAcc, ObjDBE, ObjDB, rs, UserObj, inputFile, Column, Row

    inputFile = "c:\temp\controllers.txt"
    Column = 1
    Row = 1
    CONST ForReading = 1, ForWriting = 2, ForAppending = 8
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set FSI = CreateObject("Scripting.FileSystemObject")
    Set f = fsi.OpenTextFile(inputFile, ForReading, True)
    Set objAcc = WScript.CreateObject("Access.Application")
    Set objDBE = objAcc.DBEngine
    Set objDB = objdbe.OpenDatabase("c:\temp\lastlog.mdb")
    Set rs = objDB.OpenRecordset("LASTLOG")

    'loop while reading from file
    Do While f.AtEndOfLine <> True
    DCString = f.ReadLine
    Set DomainObj = GetObject("WinNT://" & DCString)
    DomainObj.filter = array("user")
    For Each UserObj In DomainObj
    rs.Fields("UserName").Value = UserObj.Name
    rs.Fields("Description").Value = UserObj.Description
    rs.Fields("FullName").Value = UserObj.FullName
    rs.Fields("LastLogin").Value = UserObj.LastLogin
    rs.Fields("LstFldLogin").Value = UserObj.LastFailedLogin
    rs.Fields("AuthServer").Value = DCString
    rs.Fields("RunDate").Value = Date()
    Next ' Repeat for all users

    MsgBox("All Done")

  • #2
    Re: VBS script problem

    check whether there is any failed login entry.


    • #3
      Re: VBS script problem

      There is failed logon info available if I use the Additional Account Info tab that acctinfo.dll gives you in AD Users and Computers...


      • #4
        Re: VBS script problem

        As per my Knowledge these are the following properties available with the object WinNT.

        Alternatively what I can suggest you is to query the event viewer to get the time stamps.

        But I have no Idea how to do the same through vbscript/vb.


        • #5
          Re: VBS script problem

          Hmmm...I think you might have suggested the problem right there. I think the object I need to query is LDAP not WINNT for that particular property. Thanks.