Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 29th, 2004, 09:09 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking Security Event log for failed logins

Hi all,
I'm trying to write a VBScript that will check the Security Event Log in the Event Viewer for fail logins (EventID - 529). I've written a VBScript that will show events in the system log but I can't seem to get the script to find events in the security log. Any ideas?

Thanks,
Ron

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System' and " _
& "EventCode = '6008'")

Set colSecLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Security' and " _
& "EventCode = '529'")

Wscript.Echo "Unexpected shutdowns: " & colLoggedEvents.Count & _
"Failed logins: " & colSecLoggedEvents.Count
Reply With Quote
  #2 (permalink)  
Old September 29th, 2004, 10:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

It's a privileges issue. Change your GetObject call to include this part:
{impersonationLevel=impersonate,(Security)}

The ",(Security)" bit on the end makes all the difference.
Reply With Quote
  #3 (permalink)  
Old September 29th, 2004, 10:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You might want to take a look at this.

WMI and Event Logs

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to log to server's event log LenexaKS Access VBA 4 March 11th, 2008 12:49 PM
Checking the contents of a text file for log-in Seifer Classic ASP Basics 10 December 18th, 2006 12:45 PM
Event Log dkspivey ASP.NET 1.0 and 1.1 Basics 3 August 22nd, 2005 11:19 AM
AppException Class -Log Error to Event Log bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 7 December 7th, 2004 01:01 PM
Security exception comes when writing to event log s_vermani BOOK: Beginning ASP.NET 1.0 4 October 21st, 2004 09:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.