Eventlog application registration error

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Eventlog application registration error

    As I understand it from the examples in the documentation each application
    needs to get registered in order to be able to write to an event log.

    I tried to follow the example but when I run my asp.net code I get a
    security error. The implication is that the work process account doesn't
    have the correct permissions to execute the createEventSource.

    Here's the code fragment that's causing the error:

    Dim source As String = "Report Request Confirmation"

    Dim log As String = "HCS Log"

    If (Not EventLog.SourceExists(source)) Then

    EventLog.CreateEventSource(source, log)

    End If



    How do I get around this?



    -Larry


    Larry Guest

  2. Similar Questions and Discussions

    1. self registration error
      when running setup thru cd drive for program installation, receive self registration error/windows/system32/macromed/flash.ocx.
    2. Eventlog problems
      Hi All, I'm writing an webservice and want to log errors etc. and thoughed the Eventlog would be a nice place for it. The problem is that i can't...
    3. EventLog access through ASP.Net app
      I have an ASP.Net app for which I want to be able to log events to the Windows 2000 server event log under a special log name. I encountered the...
    4. [ANN] win32-eventlog 0.1.0
      Hi all, I'm happy to announce the first release of win32-eventlog. This is a Ruby interface to the Win32 EventLog. Synopsis ========...
    5. Registration related error
      Hi Im looking to find out which file holds the information for product registration, the reason for this request is I am trying out hisecwk.inf, a...
  3. #2

    Default RE: Eventlog application registration error

    Hi Larry,

    From your description, you encountered security permission issue when try
    accessing the EventLog( create a new event source ) in ASP.NET web
    application, yes?

    What about the detailed exception info it popup? I'm not sure whether
    you've read the following kb article, it have discussed a existing problem
    when you try accessing the EventLog in ASP.NET by default process
    acount(ASPNET) and provide a complete steps on creating a new event source:

    #PRB: "Requested Registry Access Is Not Allowed" Error Message When ASP.NET
    Application Tries to Write New EventSource in the EventLog
    [url]http://support.microsoft.com/?id=329291[/url]

    Please have a look to see whether it helps. Thanks.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]

    Steven Cheng[MSFT] Guest

  4. #3

    Default Re: Eventlog application registration error

    Your suggestion hasn't quite worked. Using the information you supplied did
    allow me to create a new event log (and I assume the associated sources I
    wanted) BUT I still can NOT get my web application to write any entries into
    the log. Hopefully the following will aid you in coming up with some ideas
    what to try next, as I have very little idea what permissions, and where I
    need to change to make this work; or just what I could do to get it working.

    here's my code to generate the entries:
    ----------------------------------------------------------------------------
    -------
    Private Sub write2log(ByVal logText As String, ByVal eventlogtype As Int16)

    Dim source As String = "Development Web site" ' use this source for
    development

    ' dim source as string = "NoiseShield/shades site" ' use this source for
    production

    Dim log As String = "HCS Programs"

    If (Not EventLog.SourceExists(source)) Then

    Me.errMessage.Text = "Event log source does not exist!"

    End If

    Dim aLog As EventLog

    Dim EntryType As EventLogEntryType

    Select Case eventlogtype

    Case critical

    EntryType = EventLogEntryType.Error

    Case warning

    EntryType = EventLogEntryType.Warning

    Case informational

    EntryType = EventLogEntryType.Information

    End Select

    aLog = New EventLog

    aLog.Source = source

    aLog.WriteEntry(logText, EntryType) ' <-----this is line 106 that causes
    the error

    End Sub

    ----------------------------------------------------------------------------
    ------------------------------------------------

    and here's the trace from the error page:

    ----------------------------------------------------------------------------
    ---------------------------------------------------

    Stack Trace:

    [SecurityException: Requested registry access is not allowed.]
    Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
    +473
    System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
    logName, String machineName, Boolean useMutex) +445
    System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
    type, Int32 eventID, Int16 category, Byte[] rawData) +342
    System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
    type, Int32 eventID, Int16 category) +21
    System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
    type, Int32 eventID) +15
    System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
    type) +11
    autoresponder.ReportRequestConfirmation.write2log( String logText, Int16
    eventlogtype) in C:\Documents and
    Settings\lbilodeau.OROFFICE\VSWebCache\development .froghaven.com\HCS_IT\nois
    eshield\autoresponder\reportRequestConformation.as px.vb:106





    "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
    news:d7lNF9sHEHA.612@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > From your description, you encountered security permission issue when try
    > accessing the EventLog( create a new event source ) in ASP.NET web
    > application, yes?
    >
    > What about the detailed exception info it popup? I'm not sure whether
    > you've read the following kb article, it have discussed a existing problem
    > when you try accessing the EventLog in ASP.NET by default process
    > acount(ASPNET) and provide a complete steps on creating a new event
    source:
    >
    > #PRB: "Requested Registry Access Is Not Allowed" Error Message When
    ASP.NET
    > Application Tries to Write New EventSource in the EventLog
    > [url]http://support.microsoft.com/?id=329291[/url]
    >
    > Please have a look to see whether it helps. Thanks.
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
    >

    Larry Guest

  5. #4

    Default Re: Eventlog application registration error

    Never mind. actually your solution did work. My error was to try to register
    two sources in my installation program by simply changing the source value.

    For anyone else that is following this the following does not work as
    intended, only the last source gets registered properly:

    Imports System.Diagnostics

    Imports System.Configuration.Install

    Imports System.ComponentModel

    <RunInstaller(True)> Public Class HCSEventLogInstaller

    Inherits Installer

    Private HCSEventLogInstaller As EventLogInstaller

    Public Sub New()

    HCSEventLogInstaller = New EventLogInstaller

    ' set the source of the event log to be created

    HCSEventLogInstaller.Source = "Development Web site"

    ' set the log that the source is created in

    HCSEventLogInstaller.Log = "HCS Programs"

    'add this event source to the collection

    Installers.Add(HCSEventLogInstaller)

    ' set the alternate source

    HCSEventLogInstaller.Source = "NoiseShield/shades site"

    Installers.Add(HCSEventLogInstaller)

    End Sub

    End Class



    As to how to get two sources registered in on go, I haven't a clue at this
    time.



    -Larry

    "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
    news:d7lNF9sHEHA.612@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > From your description, you encountered security permission issue when try
    > accessing the EventLog( create a new event source ) in ASP.NET web
    > application, yes?
    >
    > What about the detailed exception info it popup? I'm not sure whether
    > you've read the following kb article, it have discussed a existing problem
    > when you try accessing the EventLog in ASP.NET by default process
    > acount(ASPNET) and provide a complete steps on creating a new event
    source:
    >
    > #PRB: "Requested Registry Access Is Not Allowed" Error Message When
    ASP.NET
    > Application Tries to Write New EventSource in the EventLog
    > [url]http://support.microsoft.com/?id=329291[/url]
    >
    > Please have a look to see whether it helps. Thanks.
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
    >

    Larry Guest

  6. #5

    Default Re: Eventlog application registration error

    Take out the EventLog.SourceExists call. That is causing the security
    exception.

    Just write to the log and it should be fine. If you need to, you can put
    that part in a try/catch block in case the write fails for some reason.

    Joe K.

    "Larry" <Larry@froghaven.com> wrote in message
    news:ejK7aM2HEHA.1548@TK2MSFTNGP10.phx.gbl...
    > Your suggestion hasn't quite worked. Using the information you supplied
    did
    > allow me to create a new event log (and I assume the associated sources I
    > wanted) BUT I still can NOT get my web application to write any entries
    into
    > the log. Hopefully the following will aid you in coming up with some ideas
    > what to try next, as I have very little idea what permissions, and where I
    > need to change to make this work; or just what I could do to get it
    working.
    >
    > here's my code to generate the entries:
    > --------------------------------------------------------------------------
    --
    > -------
    > Private Sub write2log(ByVal logText As String, ByVal eventlogtype As
    Int16)
    >
    > Dim source As String = "Development Web site" ' use this source for
    > development
    >
    > ' dim source as string = "NoiseShield/shades site" ' use this source for
    > production
    >
    > Dim log As String = "HCS Programs"
    >
    > If (Not EventLog.SourceExists(source)) Then
    >
    > Me.errMessage.Text = "Event log source does not exist!"
    >
    > End If
    >
    > Dim aLog As EventLog
    >
    > Dim EntryType As EventLogEntryType
    >
    > Select Case eventlogtype
    >
    > Case critical
    >
    > EntryType = EventLogEntryType.Error
    >
    > Case warning
    >
    > EntryType = EventLogEntryType.Warning
    >
    > Case informational
    >
    > EntryType = EventLogEntryType.Information
    >
    > End Select
    >
    > aLog = New EventLog
    >
    > aLog.Source = source
    >
    > aLog.WriteEntry(logText, EntryType) ' <-----this is line 106 that
    causes
    > the error
    >
    > End Sub
    >
    > --------------------------------------------------------------------------
    --
    > ------------------------------------------------
    >
    > and here's the trace from the error page:
    >
    > --------------------------------------------------------------------------
    --
    > ---------------------------------------------------
    >
    > Stack Trace:
    >
    > [SecurityException: Requested registry access is not allowed.]
    > Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
    > +473
    > System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
    > logName, String machineName, Boolean useMutex) +445
    > System.Diagnostics.EventLog.WriteEntry(String message,
    EventLogEntryType
    > type, Int32 eventID, Int16 category, Byte[] rawData) +342
    > System.Diagnostics.EventLog.WriteEntry(String message,
    EventLogEntryType
    > type, Int32 eventID, Int16 category) +21
    > System.Diagnostics.EventLog.WriteEntry(String message,
    EventLogEntryType
    > type, Int32 eventID) +15
    > System.Diagnostics.EventLog.WriteEntry(String message,
    EventLogEntryType
    > type) +11
    > autoresponder.ReportRequestConfirmation.write2log( String logText, Int16
    > eventlogtype) in C:\Documents and
    >
    Settings\lbilodeau.OROFFICE\VSWebCache\development .froghaven.com\HCS_IT\nois
    > eshield\autoresponder\reportRequestConformation.as px.vb:106
    >
    >
    >
    >
    >
    > "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
    > news:d7lNF9sHEHA.612@cpmsftngxa06.phx.gbl...
    > > Hi Larry,
    > >
    > > From your description, you encountered security permission issue when
    try
    > > accessing the EventLog( create a new event source ) in ASP.NET web
    > > application, yes?
    > >
    > > What about the detailed exception info it popup? I'm not sure whether
    > > you've read the following kb article, it have discussed a existing
    problem
    > > when you try accessing the EventLog in ASP.NET by default process
    > > acount(ASPNET) and provide a complete steps on creating a new event
    > source:
    > >
    > > #PRB: "Requested Registry Access Is Not Allowed" Error Message When
    > ASP.NET
    > > Application Tries to Write New EventSource in the EventLog
    > > [url]http://support.microsoft.com/?id=329291[/url]
    > >
    > > Please have a look to see whether it helps. Thanks.
    > >
    > >
    > > Regards,
    > >
    > > Steven Cheng
    > > Microsoft Online Support
    > >
    > > Get Secure! [url]www.microsoft.com/security[/url]
    > > (This posting is provided "AS IS", with no warranties, and confers no
    > > rights.)
    > >
    > > Get Preview at ASP.NET whidbey
    > > [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
    > >
    >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  7. #6

    Default Re: Eventlog application registration error

    Hi Larry,

    Have you tried Joe's suggestions or have you resolved the problem, if you
    still have any problem or have any new findings, please feel free to post
    here. Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]


    Steven Cheng[MSFT] Guest

  8. #7

    Default Re: Eventlog application registration error

    I resolved the problem by creating a small consule module to create event
    sources, so at this point it's working to the client and my satisfaction.

    thanks for you guys' help.

    -Larry


    "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
    news:1NLJQohIEHA.3872@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > Have you tried Joe's suggestions or have you resolved the problem, if you
    > still have any problem or have any new findings, please feel free to post
    > here. Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > [url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
    >
    >

    Larry Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139