Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1462
  • Last Modified:

Can't Access event log through VB.Net on Windows server 2008 with IIS 7.0

I am catching errors in my web app and writing custom error messages to the application log. The application is deployed on WIndows Server 2008 running IIS 7.0. When an error occurs and tries to write to the log I get the error:

 Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

how can it be fixed? on the provided snippet the error occurs in the second line "If not eventlog.sourceexists...."

scd.MachineName = "."
        If Not EventLog.SourceExists(scd.Source, scd.MachineName) Then
               EventLog.CreateEventSource(scd)
        End If

Open in new window

0
gregx1973
Asked:
gregx1973
  • 2
1 Solution
 
philipjonathanCommented:
It's something to do with permission.
One shortcut, if you just need to run this on a specific server, you can write a Winforms app, just to create the said event log and source.
Afterwards, you would be able to use this event log and source from your web app / IIS.
0
 
gregx1973Author Commented:
but the exception does not occur when I am trying to create the source. It's happening when it checks to see if the source exists
0
 
philipjonathanCommented:
Hmm, if manage to create the event log and source somehow using Winform, you don't need to check whether it exists in your actual code.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now