Access problems trying to access my log files

T

tshad

I am trying to access my log files and am running into a permissions
problem.

I am doing the following:

******************************************************************
private void PopulateSiteBox()
{
drpSiteBox.Items.Clear();
string FILE_PATH = @"\\" +txtMachine.Text +
@"\C$\windows\System32\LogFiles\";

Trace.Warn("FILE_PATH = " + FILE_PATH);

DirectoryInfo di = new DirectoryInfo(FILE_PATH);
foreach(FileSystemInfo fsi in di.GetFileSystemInfos())
{
if(fsi.Name.StartsWith("W3"))
drpSiteBox.Items.Add(fsi.Name);
}
}
*********************************************************************

The error I am getting is on the GetFileSystemInfos() call. This is trying
to access:

FILE_PATH = \\sam\C$\windows\System32\LogFiles\

To get the W3... folder to get the name of the folder the ex040920.log is
in.

I tried to audit the folder LogFiles setting the success and failure to all
and to everyone. I wanted to find out what user is trying to access the
folder. I am not sure what user the asp.net is using.

The error I get is:

*****************************************************************************
Access to the path "\\tfs\C$\windows\System32\LogFiles\" is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path
"\\tfs\C$\windows\System32\LogFiles\" is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the
boxes for the desired access.

******************************************************************************

As I said I did try to set the permissions to everyone to solve the problem
(temporarily). This is only on my WXP Pro machine so I am not concerned
with anyone getting access to my machine.

What do I need to set to make this work?

Thanks,

Tom.
 
B

bruce barker

you cannot use a unc path, unless you give the asp.net account network
permisions. use

string FILE_PATH = @"C:\windows\System32\LogFiles\";

-- bruce (sqlwork.com)


| I am trying to access my log files and am running into a permissions
| problem.
|
| I am doing the following:
|
| ******************************************************************
| private void PopulateSiteBox()
| {
| drpSiteBox.Items.Clear();
| string FILE_PATH = @"\\" +txtMachine.Text +
| @"\C$\windows\System32\LogFiles\";
|
| Trace.Warn("FILE_PATH = " + FILE_PATH);
|
| DirectoryInfo di = new DirectoryInfo(FILE_PATH);
| foreach(FileSystemInfo fsi in di.GetFileSystemInfos())
| {
| if(fsi.Name.StartsWith("W3"))
| drpSiteBox.Items.Add(fsi.Name);
| }
| }
| *********************************************************************
|
| The error I am getting is on the GetFileSystemInfos() call. This is
trying
| to access:
|
| FILE_PATH = \\sam\C$\windows\System32\LogFiles\
|
| To get the W3... folder to get the name of the folder the ex040920.log is
| in.
|
| I tried to audit the folder LogFiles setting the success and failure to
all
| and to everyone. I wanted to find out what user is trying to access the
| folder. I am not sure what user the asp.net is using.
|
| The error I get is:
|
|
****************************************************************************
*
| Access to the path "\\tfs\C$\windows\System32\LogFiles\" is denied.
| Description: An unhandled exception occurred during the execution of the
| current web request. Please review the stack trace for more information
| about the error and where it originated in the code.
|
| Exception Details: System.UnauthorizedAccessException: Access to the path
| "\\tfs\C$\windows\System32\LogFiles\" is denied.
|
| ASP.NET is not authorized to access the requested resource. Consider
| granting access rights to the resource to the ASP.NET request identity.
| ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
or
| Network Service on IIS 6) that is used if the application is not
| impersonating. If the application is impersonating via <identity
| impersonate="true"/>, the identity will be the anonymous user (typically
| IUSR_MACHINENAME) or the authenticated request user.
|
| To grant ASP.NET write access to a file, right-click the file in Explorer,
| choose "Properties" and select the Security tab. Click "Add" to add the
| appropriate user or group. Highlight the ASP.NET account, and check the
| boxes for the desired access.
|
|
****************************************************************************
**
|
| As I said I did try to set the permissions to everyone to solve the
problem
| (temporarily). This is only on my WXP Pro machine so I am not concerned
| with anyone getting access to my machine.
|
| What do I need to set to make this work?
|
| Thanks,
|
| Tom.
|
|
|
|
|
 
T

tshad

bruce barker said:
you cannot use a unc path, unless you give the asp.net account network
permisions. use

string FILE_PATH = @"C:\windows\System32\LogFiles\";

I gave LogFiles Everyone access to everything ( I assume that that would
include the asp.net Account). Do I also have to do it for the "windows" and
"System32" folders?

How do I tell what the asp.net account is? That was what I was trying to do
when I set up auditing on the LogFiles folder, but there was nothing in the
event viewer for it.

Could that have been because it was actually getting the error on the
"windows" or "system32" folder?

Thanks,

Tom.
 
T

tshad

Patrick Olurotimi Ige said:
Hi Tom,
Did you get it working?

Not yet.

I am going to try to put access permissions on a file in my asp.net
application folder and try to open it it and see who the user is.

This whole permission thing has always been my downfall. All the
local/global permissions has always driven me crazy when I am trying to set
up service or schedular task or stored procedure. It invariably happens
that there is some function I am trying to execute that needs some special
access permission that I need to figure out.

Tom
 
P

Patrick Olurotimi Ige

Hi Tom,
As Bruce explained you cannot use a unc path, unless you give the
asp.net account network permisions.
I have developed a similar application and i had to give asp.net
account network permisions(but uploading!)
What exact error are u getting now after granting ASP.NET.
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top