Hi Jerry,
Can you first confirm if you are using VS2005 or VS.net2003 in the project?
Below is the source code of System.Diagnost ics.EventLog.Op enForWrite()
method:
private void OpenForWrite()
{
if (this.disposed)
{
throw new ObjectDisposedE xception(base.G etType().Name);
}
if ((this.sourceNa me == null) || this.sourceName .Equals(string. Empty))
{
throw new ArgumentExcepti on(SR.GetString ("NeedSourceToO pen"));
}
SharedUtils.Che ckEnvironment() ;
this.writeHandl e =
UnsafeNativeMet hods.RegisterEv entSource(this. machineName, this.sourceName );
if (this.writeHand le == IntPtr.Zero)
{
Win32Exception exception1 = null;
if (Marshal.GetLas tWin32Error() != 0)
{
exception1 = EventLog.Create SafeWin32Except ion();
}
throw new
InvalidOperatio nException(SR.G etString("CantO penLogAccess"), exception1);
}
}
With the code, we can determine that your code fails in RegisterEventSo urce
win32 API calling.
In the document below, you will see that the RegisterEventSo urce needs
ELF_LOGFILE_WRI TE permission:
"Event Logging Security"
http://windowssdk.msdn.microsoft.com.../ms684080.aspx
Since your code runs well on my test environment, I suspect if the account
your exeuction thread runs under has some different feature. Can you tell
me what authentication mode you are using in you Asp.net project? Basic
authentication or Windows authentication? Do you use any impersonation in
your project?
In your LoginV6.Page_Lo ad method, I recommend you print out the following
information on the page for troubleshooting purpose:
Imports System.Diagnost ics
Imports System.Security .Principal
Public Class WebForm1
Inherits System.Web.UI.P age
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim id As IIdentity = WindowsIdentity .GetCurrent()
Me.Response.Wri te(id.Name + "<br>")
Me.Response.Wri te(id.IsAuthent icated.ToString () + "<br>")
Me.Response.Wri te(id.Authentic ationType + "<br>")
.....
End Sub
End Class
Please provide the output information to me. Thanks.
Once you determined the running account of the current thread, you may
modify the DACL setting of eventlog in registry with SDDL format.
On W2K3, the security of Application Event Log is controlled by CustomSD
registry value in key below:
HKEY_LOCAL_MACH INE\SYSTEM\Curr entControlSet\S ervices\Eventlo g\Application
CustomSD REG_SZ registry value is described by default in SDDL format as
below:
O:BAG:SYD:(D;;0 xf0007;;;AN)(D; ;0xf0007;;;BG)( A;;0xf0007;;;SY )(A;;0x7;;;BA)( A
;;0x7;;;SO)(A;; 0x3;;;IU)(A;;0x 3;;;SU)(A;;0x3; ;;S-1-5-3)
In order for any authenticated user to be able to write to Application
Event Log, you will append:
(A;;0x3;;;AU)
where AU is referring "Authentica ted Users".
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.