473,480 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Read from the event Viewer

4 New Member
Hello,

I have a small question.
I am using asp .net 2.0 and i am trying to read from the event viewer and display in a console the users that have logged on the computer, first and last logon/logout hour.
I am not getting verry far:
this is what i wrote so far:

EventLog myNewLog = new EventLog();
myNewLog.Log = "Security";
foreach (EventLogEntry entry in myNewLog.Entries)
{
EventLog.GetEventLogs();
Console.WriteLine("\tEntry:" + entry.Message);

}

// if (EventLogEntryType.SuccessAudit && ) -> the type has to be SuccessAudit, the Category has to be Logon/Logoff but i can't find eventlog.category or something like that.

Can anyone help me please?
Aug 10 '07 #1
2 1913
kenobewan
4,871 Recognized Expert Specialist
Here is an article that may give you a start:
Build a Really Useful ASP.NET Exception Engine
Aug 10 '07 #2
d33a
4 New Member
ok, so i did it, after a vacation :)
my only problem is that i want to ignore the Logon Type 7(from the eventLogEntry Message) because that means the workstation was unlocked/locked. Does anybody have any idea (except the parsing of the string, doesn't help me because the event log with the id 551 doesn't have a Logon Type in the message).

This is the function that does the search

public static ArrayList EventLogSearch(string username, DateTime myLastEntryInText, Boolean firstRun)
{
ArrayList intrari = new ArrayList();
EventLog myNewLog = new EventLog();
myNewLog.Log = "Security";
foreach (EventLogEntry entry in myNewLog.Entries)
{
if (firstRun == false)
{
if (

entry.UserName.Equals(username) &&
entry.TimeGenerated.Date > myLastEntryInText.Date &&
entry.TimeGenerated.Date != DateTime.Today &&
(entry.InstanceId.Equals(528) || entry.InstanceId.Equals(551) || entry.InstanceId.Equals(538))
)
{
if (!(intrari.Count == 0 && entry.InstanceId.Equals(551)))
intrari.Add(entry.TimeGenerated.ToString());
Console.WriteLine(entry.EntryType.ToString());
}
}
else
{
if (
entry.UserName.Equals(username) &&
entry.TimeGenerated.Date == myLastEntryInText.Date &&
(entry.InstanceId.Equals(528) || entry.InstanceId.Equals(551) || entry.InstanceId.Equals(538))
)
{
// If the first event is logoff then ignore
if (!(intrari.Count == 0 && entry.InstanceId.Equals(538)))
{
intrari.Add(entry.TimeGenerated.ToString());

}
}
}
}
return intrari;
}
Aug 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1578
by: Avinash P. | last post by:
Hi All, My mmc snapin application written in c# logs all its events in custom event source that we have created for this application. When any error occurs the application also displays a...
1
3596
by: Tressa | last post by:
I have a Csharp windows service that currently uses socketing to communicate to additional PC's to shutdown or restart. I need to also have this service open up the Event Viewer and search for...
29
15471
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
0
1311
by: dp | last post by:
hello, I have service that copy dll file that contain information of one of the sources of the event viewer. the service is in system permission. if someone used event viewer before the process ,...
1
2856
by: Jorge Luzarraga Castro | last post by:
Helloo, I´ve got a ASP .Net application which writes to the event viewer whenever it finds a error. This appl needs to create a new section in the event viewer the first time it encounters any...
0
1748
by: chrisexv6 | last post by:
Running a webservice under IIS 5.0, we've recently started seeing COM+ errors in Event Viewer. The details are: Event Type: Error Event Source: COM+ Event Category: SVC Event ID: 4194...
3
14625
by: Mike | last post by:
I know there are server tools out there for this but are admins won't run them on test servers. what I need is a way to read the event view --system for a particular event. I need this to run...
1
4128
by: dotyet | last post by:
Hi Everyone, I am looking at a lot of entries similar to the following in my Windows 'Audit' Event viewer. They are all success events and not failures. The environment is: DB2 8.2 FP 14...
1
2832
by: anithaapr05 | last post by:
I have got the warning in event viewer when i wrote the code in global.asax session_end(). When the user sessions time out, the Session_End event fires successfully.But i got the waring in event...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.