ASP.NET: Event Log in IIS6/Server 2003

by Brad 6. March 2008 11:44

If you want to write to the Server's Event log from ASP.NET you'll first need to tweak some security settings. The first change is easy, however the second took me a while to find.

Step One:

Grant "Full Control" to the "IIS_WPG" group to the following registry key:

HKLM\SYSTEM\CurrentControlSet\Services\EventLog

Step Two:

One of the security restrictions added to IIS 6 under Windows Server 2003 was much tighter ACLs (Access Control Lists) on the event logs. This restricts what accounts can read and write to the logs (application, system & security). To overcome this you'll need to add the following value. Incase you're worried what security hole I'm opening up for you there's a breakdown of what it means at the end of the post.

(A;;0x0002;;;AU)

Add the above value to the end of the existing "CustomSD" value found at following path (pick relevant one):

HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application

HKLM\SYSTEM\CurrentControlSet\Services\EventLog\System

HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Security

So mine went from:

O:BAG:SYD:(D;;0xf0007;;;AN)(D;;0xf0007;;;BG)(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)

to: (scroll to all the way to the right to see the change in bold):

O:BAG:SYD:(D;;0xf0007;;;AN)(D;;0xf0007;;;BG)(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x0002;;;AU)

The value being added is written in Security Descriptor Definition Language (SDDL) and is as follows:

  • A = Access allowed.
  • ;; = token delimiter (don't know why there's two of them?)
  • 0x0002 = Permission to write log files.
  • ;;; = token delimiter (again - don't know why there's three of them?)
  • AU = Authenticated Users.

Tags:

ASP.NET AJAX | Microsoft Server 2003

Comments

4/7/2008 4:24:29 PM #

To answer the questions about the semicolons.

The ACEs are specified in the following format:

ace_type;ace_flags;rights;object_guid;inherit_object_guid;account_sid

You can find the full documentation for security descriptor strings in the Microsoft Windows Platform SDK.  The main articles are:

msdn2.microsoft.com/.../aa374928(VS.85).aspx

and

msdn2.microsoft.com/.../aa379570(VS.85).aspx

The beginning of the SD is harder to read because there isn't a separator between sections.  In the above sections, the first section is O:BA and G:SY which means Owner:Built-in Administrators, Owner Group: Local System.

I wouldn't advise changing the rights to Authenticated Users because that leaves a large security hole.  Instead, either add the particular user account that ASP.NET uses (the default Network Service account already has permissions, I believe) or create an isolated component with appropriate permissions, perhaps using a web service or .NET remoting.

Stephen Horsfield |

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar