Home All Groups Group Topic Archive Search About

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

Author
1 May 2006 4:33 PM
John
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

Author
1 May 2006 4:40 PM
Nicholas Paldino [.NET/C# MVP]
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

Show quote
"John" <john***@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegroups.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
>
Author
1 May 2006 6:44 PM
John
if throw exception the following exception:

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


Nicholas Paldino [.NET/C# MVP] wrote:
Show quote
> 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" <john***@yahoo.com> wrote in message
> news:1146501188.315736.13980@v46g2000cwv.googlegroups.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
> >
Author
1 May 2006 4:49 PM
Willy Denoyette [MVP]
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.

Show quote
"John" <john***@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegroups.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
|
Author
1 May 2006 5:24 PM
Joe Kaplan (MVP - ADSI)
Try this article:

http://msdn.microsoft.com/msdnmag/issues/05/10/Auditing/default.aspx

Joe K.

Show quote
"John" <john***@yahoo.com> wrote in message
news:1146501188.315736.13980@v46g2000cwv.googlegroups.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
>
Author
1 May 2006 6:59 PM
John
Looks like it only works for WIndows 2003, not Windox XP
Author
1 May 2006 7:08 PM
Willy Denoyette [MVP]
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.


Show quote
"John" <john***@yahoo.com> wrote in message
news:1146509954.795586.193810@j73g2000cwa.googlegroups.com...
| Looks like it only works for WIndows 2003, not Windox XP
|
Author
25 May 2006 2:06 PM
Kevin
Try this:  http://support.microsoft.com/kb/323076


Show quote
"Willy Denoyette [MVP]" wrote:

> 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" <john***@yahoo.com> wrote in message
> news:1146509954.795586.193810@j73g2000cwa.googlegroups.com...
> | Looks like it only works for WIndows 2003, not Windox XP
> |
>
>
>
Author
25 May 2006 4:17 PM
Willy Denoyette [MVP]
"Kevin" <Ke***@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.

AddThis Social Bookmark Button