Connecting Tech Pros Worldwide Forums | Help | Site Map

Very Easy Question, How to write log to SECURTY Event Log? Please help

John
Guest
 
Posts: n/a
#1: May 1 '06
Is there any special code I have to write to log event to Security
Event Log? The following code give me "Very Easy Question, How to
write log to SECURTY Event Log? Please help" Error

// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "Security";

// Write an informational entry to the event log.
myLog.WriteEntry("Writing warning to event log.",
EventLogEntryType.Warning);


but as soon as I change "Security" to "Application" ,
everything works fine

// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "Application";

// Write an informational entry to the event log.
myLog.WriteEntry("Writing warning to event log.",
EventLogEntryType.Warning);


Any ideas?
Thanks in advance
John


Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#2: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


John,

What happens when you try and write to the security event log? Do you
get an exception or something of that nature? If so, what is it?


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"John" <johnxhc@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegro ups.com...[color=blue]
> Is there any special code I have to write to log event to Security
> Event Log? The following code give me "Very Easy Question, How to
> write log to SECURTY Event Log? Please help" Error
>
> // Create an EventLog instance and assign its source.
> EventLog myLog = new EventLog();
> myLog.Source = "Security";
>
> // Write an informational entry to the event log.
> myLog.WriteEntry("Writing warning to event log.",
> EventLogEntryType.Warning);
>
>
> but as soon as I change "Security" to "Application" ,
> everything works fine
>
> // Create an EventLog instance and assign its source.
> EventLog myLog = new EventLog();
> myLog.Source = "Application";
>
> // Write an informational entry to the event log.
> myLog.WriteEntry("Writing warning to event log.",
> EventLogEntryType.Warning);
>
>
> Any ideas?
> Thanks in advance
> John
>[/color]


Willy Denoyette [MVP]
Guest
 
Posts: n/a
#3: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


Only administrator can read from the security log, but user programs cannot
write to the security log, this is a privilege of the security subsystem
only.

Willy.

"John" <johnxhc@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegro ups.com...
| Is there any special code I have to write to log event to Security
| Event Log? The following code give me "Very Easy Question, How to
| write log to SECURTY Event Log? Please help" Error
|
| // Create an EventLog instance and assign its source.
| EventLog myLog = new EventLog();
| myLog.Source = "Security";
|
| // Write an informational entry to the event log.
| myLog.WriteEntry("Writing warning to event log.",
| EventLogEntryType.Warning);
|
|
| but as soon as I change "Security" to "Application" ,
| everything works fine
|
| // Create an EventLog instance and assign its source.
| EventLog myLog = new EventLog();
| myLog.Source = "Application";
|
| // Write an informational entry to the event log.
| myLog.WriteEntry("Writing warning to event log.",
| EventLogEntryType.Warning);
|
|
| Any ideas?
| Thanks in advance
| John
|


Joe Kaplan \(MVP - ADSI\)
Guest
 
Posts: n/a
#4: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


Try this article:

http://msdn.microsoft.com/msdnmag/is...g/default.aspx

Joe K.

"John" <johnxhc@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegro ups.com...[color=blue]
> Is there any special code I have to write to log event to Security
> Event Log? The following code give me "Very Easy Question, How to
> write log to SECURTY Event Log? Please help" Error
>
> // Create an EventLog instance and assign its source.
> EventLog myLog = new EventLog();
> myLog.Source = "Security";
>
> // Write an informational entry to the event log.
> myLog.WriteEntry("Writing warning to event log.",
> EventLogEntryType.Warning);
>
>
> but as soon as I change "Security" to "Application" ,
> everything works fine
>
> // Create an EventLog instance and assign its source.
> EventLog myLog = new EventLog();
> myLog.Source = "Application";
>
> // Write an informational entry to the event log.
> myLog.WriteEntry("Writing warning to event log.",
> EventLogEntryType.Warning);
>
>
> Any ideas?
> Thanks in advance
> John
>[/color]


John
Guest
 
Posts: n/a
#5: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


if throw exception the following exception:

Cannot open log for source 'Security'. You may not have write access.


Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> John,
>
> What happens when you try and write to the security event log? Do you
> get an exception or something of that nature? If so, what is it?
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "John" <johnxhc@yahoo.com> wrote in message
> news:1146501188.315736.13980@v46g2000cwv.googlegro ups.com...[color=green]
> > Is there any special code I have to write to log event to Security
> > Event Log? The following code give me "Very Easy Question, How to
> > write log to SECURTY Event Log? Please help" Error
> >
> > // Create an EventLog instance and assign its source.
> > EventLog myLog = new EventLog();
> > myLog.Source = "Security";
> >
> > // Write an informational entry to the event log.
> > myLog.WriteEntry("Writing warning to event log.",
> > EventLogEntryType.Warning);
> >
> >
> > but as soon as I change "Security" to "Application" ,
> > everything works fine
> >
> > // Create an EventLog instance and assign its source.
> > EventLog myLog = new EventLog();
> > myLog.Source = "Application";
> >
> > // Write an informational entry to the event log.
> > myLog.WriteEntry("Writing warning to event log.",
> > EventLogEntryType.Warning);
> >
> >
> > Any ideas?
> > Thanks in advance
> > John
> >[/color][/color]

John
Guest
 
Posts: n/a
#6: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


Looks like it only works for WIndows 2003, not Windox XP

Willy Denoyette [MVP]
Guest
 
Posts: n/a
#7: May 1 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


True. As I said in my previous answer, you can't write to the Security log
from user code. Even the code as presented in the article needs elevated
privileges to register a provider and the program needs to run with
'SeAuditingPrivileges' enabled, something you don't want to do from regular
user applications, only very security conscious services need this.
Why do you want to write to the security log anyway, applications and
services should write to the 'Application' log or a private log.

Willy.


"John" <johnxhc@yahoo.com> wrote in message
news:1146509954.795586.193810@j73g2000cwa.googlegr oups.com...
| Looks like it only works for WIndows 2003, not Windox XP
|


Kevin
Guest
 
Posts: n/a
#8: May 25 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help


Try this: http://support.microsoft.com/kb/323076


"Willy Denoyette [MVP]" wrote:
[color=blue]
> True. As I said in my previous answer, you can't write to the Security log
> from user code. Even the code as presented in the article needs elevated
> privileges to register a provider and the program needs to run with
> 'SeAuditingPrivileges' enabled, something you don't want to do from regular
> user applications, only very security conscious services need this.
> Why do you want to write to the security log anyway, applications and
> services should write to the 'Application' log or a private log.
>
> Willy.
>
>
> "John" <johnxhc@yahoo.com> wrote in message
> news:1146509954.795586.193810@j73g2000cwa.googlegr oups.com...
> | Looks like it only works for WIndows 2003, not Windox XP
> |
>
>
>[/color]
Willy Denoyette [MVP]
Guest
 
Posts: n/a
#9: May 25 '06

re: Very Easy Question, How to write log to SECURTY Event Log? Please help



"Kevin" <Kevin@discussions.microsoft.com> wrote in message
news:38CFD19E-E364-41D0-BF10-DA7B2503BF71@microsoft.com...
| Try this: http://support.microsoft.com/kb/323076
|
|

Why? This does explain how to set 'Application' and 'System' eventlog
security, it doesn't say you can write to the 'Security' log because you
can't.

Willy.


Closed Thread