Custom Event Log Write Error

Discussion in 'ASP .Net Security' started by TJO, Nov 26, 2003.

  1. TJO

    TJO Guest

    We are experiencing the following error when writing to a custom log file:
    "Requested registry access is not allowed."

    We have created the custom log file using the code below and then add full
    permissions to the ASPNET account at the Registry Key
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.

    We do not experience the error when writing to the "Application" Event log
    or if we run the code from a windows form application.

    // Code Fails when writing to custom event log "SR_AppLog
    EventLog appLog = new EventLog("SR_AppLog", ".");
    appLog.Source = "SR_AppDev";
    appLog.WriteEntry("foo bar: database error");
    appLog.Dispose();


    //Code executs when writing to "Application" event log
    EventLog appLog = new EventLog("Application");
    appLog.Source = "SR_AppSrc";
    appLog.WriteEntry("foo bar: database error");
    appLog.Dispose();

    //Installer class to create the custom event log
    namespace EventLogSourceInstaller

    {

    [RunInstaller(true)]

    public class MyEventLogInstaller : Installer

    {

    private EventLogInstaller myEventLogInstaller;

    public MyEventLogInstaller()

    {

    //Create Instance of EventLogInstaller

    myEventLogInstaller = new EventLogInstaller();

    // Set the Source of Event Log, to be created.

    myEventLogInstaller.Source = "SR_AppDev";

    // Set the Log that source is created in

    myEventLogInstaller.Log = "SR_AppLog";


    // Add myEventLogInstaller to the Installers Collection.

    Installers.Add(myEventLogInstaller);

    }

    }

    }
     
    TJO, Nov 26, 2003
    #1
    1. Advertising

  2. Have a look at that:
    329291 PRB: "Requested Registry Access Is Not Allowed" Error Message When
    http://support.microsoft.com/?id=329291

    Cheers,
    Stefano Pronti

    Microsoft Developer Support

    This posting is provided "AS IS" with no warranties, and confers no rights.


    "TJO" <> wrote in message
    news:...
    > We are experiencing the following error when writing to a custom log file:
    > "Requested registry access is not allowed."
    >
    > We have created the custom log file using the code below and then add full
    > permissions to the ASPNET account at the Registry Key
    > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
    >
    > We do not experience the error when writing to the "Application" Event log
    > or if we run the code from a windows form application.
    >
    > // Code Fails when writing to custom event log "SR_AppLog
    > EventLog appLog = new EventLog("SR_AppLog", ".");
    > appLog.Source = "SR_AppDev";
    > appLog.WriteEntry("foo bar: database error");
    > appLog.Dispose();
    >
    >
    > //Code executs when writing to "Application" event log
    > EventLog appLog = new EventLog("Application");
    > appLog.Source = "SR_AppSrc";
    > appLog.WriteEntry("foo bar: database error");
    > appLog.Dispose();
    >
    > //Installer class to create the custom event log
    > namespace EventLogSourceInstaller
    >
    > {
    >
    > [RunInstaller(true)]
    >
    > public class MyEventLogInstaller : Installer
    >
    > {
    >
    > private EventLogInstaller myEventLogInstaller;
    >
    > public MyEventLogInstaller()
    >
    > {
    >
    > //Create Instance of EventLogInstaller
    >
    > myEventLogInstaller = new EventLogInstaller();
    >
    > // Set the Source of Event Log, to be created.
    >
    > myEventLogInstaller.Source = "SR_AppDev";
    >
    > // Set the Log that source is created in
    >
    > myEventLogInstaller.Log = "SR_AppLog";
    >
    >
    > // Add myEventLogInstaller to the Installers Collection.
    >
    > Installers.Add(myEventLogInstaller);
    >
    > }
    >
    > }
    >
    > }
    >
    >
     
    Stefano Pronti [MS], Nov 28, 2003
    #2
    1. Advertising

  3. TJO

    TJO Guest

    we have followed these instructions on your recommended article. The
    problem with the article is that it explains how to set permission for the
    "Application" event log. It then goes on to show how to create your own
    Even Log using a custom installer class which is also what we have done.
    Our problem is that we can write to the Application event log but not to the
    custom event log. We only get the Acccess not allowed error when writing to
    the custom event log. Writing to the Application event log is no problem.

    Has anyone done this before? What sercurity setting should I look for ?



    "Stefano Pronti [MS]" <> wrote in message
    news:%...
    > Have a look at that:
    > 329291 PRB: "Requested Registry Access Is Not Allowed" Error Message When
    > http://support.microsoft.com/?id=329291
    >
    > Cheers,
    > Stefano Pronti
    >
    > Microsoft Developer Support
    >
    > This posting is provided "AS IS" with no warranties, and confers no

    rights.
    >
    >
    > "TJO" <> wrote in message
    > news:...
    > > We are experiencing the following error when writing to a custom log

    file:
    > > "Requested registry access is not allowed."
    > >
    > > We have created the custom log file using the code below and then add

    full
    > > permissions to the ASPNET account at the Registry Key
    > > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog.
    > >
    > > We do not experience the error when writing to the "Application" Event

    log
    > > or if we run the code from a windows form application.
    > >
    > > // Code Fails when writing to custom event log "SR_AppLog
    > > EventLog appLog = new EventLog("SR_AppLog", ".");
    > > appLog.Source = "SR_AppDev";
    > > appLog.WriteEntry("foo bar: database error");
    > > appLog.Dispose();
    > >
    > >
    > > //Code executs when writing to "Application" event log
    > > EventLog appLog = new EventLog("Application");
    > > appLog.Source = "SR_AppSrc";
    > > appLog.WriteEntry("foo bar: database error");
    > > appLog.Dispose();
    > >
    > > //Installer class to create the custom event log
    > > namespace EventLogSourceInstaller
    > >
    > > {
    > >
    > > [RunInstaller(true)]
    > >
    > > public class MyEventLogInstaller : Installer
    > >
    > > {
    > >
    > > private EventLogInstaller myEventLogInstaller;
    > >
    > > public MyEventLogInstaller()
    > >
    > > {
    > >
    > > //Create Instance of EventLogInstaller
    > >
    > > myEventLogInstaller = new EventLogInstaller();
    > >
    > > // Set the Source of Event Log, to be created.
    > >
    > > myEventLogInstaller.Source = "SR_AppDev";
    > >
    > > // Set the Log that source is created in
    > >
    > > myEventLogInstaller.Log = "SR_AppLog";
    > >
    > >
    > > // Add myEventLogInstaller to the Installers Collection.
    > >
    > > Installers.Add(myEventLogInstaller);
    > >
    > > }
    > >
    > > }
    > >
    > > }
    > >
    > >

    >
    >
     
    TJO, Nov 28, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik_the_boss
    Replies:
    0
    Views:
    2,656
    Henrik_the_boss
    Nov 5, 2003
  2. Eniac
    Replies:
    1
    Views:
    8,965
    shefali.grover
    Aug 1, 2008
  3. Petterson Mikael

    Write to error log using redirect:write

    Petterson Mikael, Sep 11, 2006, in forum: XML
    Replies:
    1
    Views:
    842
    Joe Kesselman
    Sep 11, 2006
  4. JimLad
    Replies:
    0
    Views:
    620
    JimLad
    Jan 26, 2010
  5. Replies:
    0
    Views:
    1,308
Loading...

Share This Page