2008 displaying the task category vista event logs

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

2008 displaying the task category vista event logs

 
0
  #1
Jan 19th, 2009
Hi all,

I am currently displaying the information stored in the security logs in event viewer in vista.

But i cannot get the category task to display like it is in vista (Special logon, logon, audit policy change)

when i use evententry.category.tostring it just displays a number.

Anyone know how to fix this
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: 2008 displaying the task category vista event logs

 
0
  #2
Jan 20th, 2009
when i use evententry.category.tostring it just displays a number.
What number do you get? If you get "0" (or "(0)") then the category is "None". Have you checked with Event Viewer app what category names you should get?

This is the "basic" code to dump event log
  1. Dim oEvLog As EventLog
  2. Dim oEvEntry As EventLogEntry
  3.  
  4. oEvLog = New EventLog("Security")
  5.  
  6. For Each oEvEntry In oEvLog.Entries
  7. Debug.Print(oEvEntry.Category)
  8. Next
and you use similar code?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

Re: 2008 displaying the task category vista event logs

 
0
  #3
Jan 20th, 2009
i get numbers instead of the text, so i will get 50399 or 104 instead of Special logon, logon, or audit policy change
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: 2008 displaying the task category vista event logs

 
0
  #4
Jan 20th, 2009
Here's what MSDN says about EventLogEntry.CategoryNumber
The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string.
I checked the code in Vista. For some reason Security event categories were all dumped as CategoryNumber. I checked Application event categories and I got category numbers but also textual category names when one existed.

So, if you want to get names for the categories, instead of the category numbers, you'll have to find which is the resource file and use category number to get textual name directly from the resource file.

I'm just guessing how this should be done. There may be a much better way to do it, I just didn't figure it out.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: 2008 displaying the task category vista event logs

 
0
  #5
Jan 20th, 2009
Have you tried just

EventLogEntry.Category ? (I saw you said evententry.category)

http://msdn.microsoft.com/en-us/libr...ry(VS.80).aspx

msdn says that this gets the text associated with the number, that doesn't work?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: 2008 displaying the task category vista event logs

 
0
  #6
Jan 20th, 2009
Yes. That's what the code above (post #2) used. The problem is that EventLogEntry.Category returns EventLogEntry.CategoryNumber if there's no text (= localized string) associated with CategoryNumber. Not exactly a problem, it's supposed to work that way.

The problem came while dumping "Security" event log in Vista. EventLogEntry.Category always returned EventLogEntry.CategoryNumber for some reason.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: 2008 displaying the task category vista event logs

 
0
  #7
Jan 20th, 2009
Sorry Teme I totally read past that, I see it now.

The problem was found by someone writing C# as well and there is a solution, so it has to translate to vb.net as well. I'm just not experienced enough to do this well.

http://www.codeguru.com/forum/archiv.../t-264190.html

the full C# code was here http://www.codeproject.com/KB/system/sysevent.aspx

it's the format message that needs to happen right?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: 2008 displaying the task category vista event logs

 
0
  #8
Jan 20th, 2009
Code was for WinNT event log. I downloaded that project and it didn't work in XP. And the most important thing, category name, was missing. Maybe WinNT didn't have category names(?).

Also the OP (in that CodeGuru thread) ended to the same conclusion:
RookieRitwik September 23rd, 2003, 02:26 AM
I got the user name working. It uses lookupsid account. However I cant get the event category. I only get numbers.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: 2008 displaying the task category vista event logs

 
0
  #9
Jan 20th, 2009
You're right, I stand corrected. It looked like they did this to add it to XP though

  1. ' Setup the dataset
  2. ' (Don't forget to set the DataType of the "Date/Time" column)
  3. ds = New DataSet("EventLog Entries")
  4. ds.Tables.Add("Events")
  5. With ds.Tables("Events")
  6. .Columns.Add("Type")
  7. .Columns.Add("Date/Time")
  8. .Columns("Date/Time").DataType = GetType(System.DateTime)
  9. .Columns.Add("Message")
  10. .Columns.Add("Source")
  11. .Columns.Add("Category")
  12. .Columns.Add("EventID")
  13. End With
  14.  
  15. ...
  16.  
  17. ' Set the column type of the DataGridView as well!
  18. If col.Name = "Date/Time" Then
  19. col.ValueType = GetType(System.DateTime)
  20. End If

will that work with what he wants to do? They are manually setting the header right?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC