Website Event Log Errors
-
Friday, March 22, 2013 5:02 PM
Windows 2008 R2
Impersonation is enabled and anon access with the IUSR no SID.
Standard method to insert a log, the source exists, already created it with an installer.
Locally on my dev box works great, but user is me administrator, on Windows 2003 code works fine too, it's not until i use IIS 7 on Windows 2008 do i get the following error:
Current User: NT AUTHORITY\IUSR SSID:
Create Eventlog Item Exits?: True
Create Eventlog Item Error?: False
Insert Eventlog Error?: True
ex.Message
Cannot open log for source 'Magellan Client Services'. You may not have write access.
ex.Source
System
ex.StackTrace
at System.Diagnostics.EventLogInternal.OpenForWrite(String currentMachineName) at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName) at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type) at Utility_eventlogtest.Page_Load(Object sender, EventArgs e) in d:\Staging\ClientServices\Utility\eventlogtest.aspx.cs:line 36
ex.InnerException.Message
Access is denied
ex.InnerException.Souce
ex.InnerException.StackTraceCode:
eventlogtest.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Utility_eventlogtest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bool create = false;
bool err = false;
bool eventlog = false;
string currentuser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
var httpuser = HttpContext.Current.User.Identity as System.Security.Principal.WindowsIdentity;
string ssid = "";
try
{
try
{
ssid = httpuser.User.ToString();
}
catch { }
if (!System.Diagnostics.EventLog.SourceExists("Magellan Client Services"))
{
create = true;
System.Diagnostics.EventLog.CreateEventSource("Magellan Client Services", "Application");
}
else
{
eventlog = true;
}
err = true;
System.Diagnostics.EventLog.WriteEntry("Magellan Client Services", "Test Entry", System.Diagnostics.EventLogEntryType.SuccessAudit);
}
catch (HttpException)
{
lblHttpMsg.Text = "Http exception caught";
}
catch (Exception ex)
{
lblMsg.Text = "<B>ex.Message</b><BR />" + ex.Message + "<br><b>ex.Source</b><BR />" + ex.Source + "<br><b>ex.StackTrace</b><BR />" + ex.StackTrace + "<br><B>ex.InnerException.Message</b><br />" + ex.InnerException.Message + "<br><B>ex.InnerException.Souce</b><br />" + ex.InnerException.Source + "<br><B>ex.InnerException.StackTrace</b><br />" + ex.InnerException.StackTrace;
}
finally
{
lblMsg.Text = "Current User: " + currentuser + " SSID: " + ssid + "<BR>Create Eventlog Item Exits?: " +eventlog+ "<BR>Create Eventlog Item Error?: " +create+"<BR>Insert Eventlog Error?: " + err + "<BR />" + lblMsg.Text;
}
}
}eventlogtest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="eventlogtest.aspx.cs" Inherits="Utility_eventlogtest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblMsg" runat="server"></asp:Label>
<asp:Label ID="lblHttpMsg" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
All Replies
-
Friday, March 22, 2013 5:40 PM
Might want to ask them over here.
http://social.msdn.microsoft.com/Forums/en-US/category/vslanguages
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.- Marked As Answer by Santosh BhandarkarMicrosoft Community Contributor, Moderator Saturday, March 23, 2013 7:43 AM
-
Friday, March 22, 2013 5:44 PMAwesome thanks, I entered via technet and did not see an IIS forum in the listing.
-
Friday, March 22, 2013 5:46 PM
You're welcome.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

