Groups | Blog | Home
all groups > dotnet security > october 2004 >

dotnet security : System.ComponentModel.Win32Exception: Access is denied


DotNetJunkies User
10/26/2004 11:51:08 PM
hi

while trying to execute the following program i am getting "System.ComponentModel.Win32Exception: Access is denied" as errror message.


<% @Page Language="C#" %>
<% @Import Namespace="System.Diagnostics" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
BindGrid();
}

void LogGrid_Change(Object sender, DataGridPageChangedEventArgs e)
{
// Set CurrentPageIndex to the page the user clicked.
LogGrid.CurrentPageIndex = e.NewPageIndex;

// Rebind the data.
BindGrid();
}

void BindGrid()
{
EventLog aLog = new EventLog();
aLog.Log = "System";
aLog.MachineName = ".";

LogGrid.DataSource = aLog.Entries;
LogGrid.DataBind();
}
</script>
<body bgcolor="#ffffff">

<h3>System Event Log</h3>

<form runat="server">
<asp:DataGrid id="LogGrid" runat="server"
AllowPaging="True"
PageSize="10"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Right"
PagerStyle-NextPageText="Next"
PagerStyle-PrevPageText="Prev"
OnPageIndexChanged="LogGrid_Change"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
AutoGenerateColumns="false">
<Columns>
<asp:BoundColumn HeaderText="TOF" DataField="EntryType" />
<asp:BoundColumn HeaderText="Date/Time" DataField="TimeGenerated"/>
<asp:BoundColumn HeaderText="Source" DataField="Source"/>
<asp:BoundColumn HeaderText="Event ID" DataField="EventID"/>
</Columns>
</asp:DataGrid>
</form>

</body>
</html>

---
Posted using Wimdows.net NntpNews Component -

Nicole Calinoiu
10/27/2004 7:38:07 AM
The Windows user account that defines the user context for this process will
need read permissions on the following registry key in order to enable
reading from the system event log:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security.

If you're not sure how to verify or change permissions on a registry key,
see http://support.microsoft.com/default.aspx?scid=kb;en-us;310426.

If you're not sure how to verify or change the user context for your web
application, see
http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetAP05.asp.

HTH,
Nicole


[quoted text, click to view]

AddThis Social Bookmark Button