IIS Server - How to access file on the Network drive from asp.net

This is Interesting: Free IT Magazines  
Home > Archive > IIS Server > June 2005 > How to access file on the Network drive from asp.net





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to access file on the Network drive from asp.net
Daniel

2005-06-27, 5:53 pm

Hi all,

I had a asp.net application that needs to access to a text file on the map
drive. The application use an impersonate user account. Originally, this
asp.net application runs on a Windows 2000 server and I don't have any
problem accessing a file on the other Windows 2000 server. The share folder
already mapped on the server that run the asp.net application.

The problem is the asp.net can not access to the same map drive when I move
the it to a Windows 2003 server. The impersonate user account on the
Windows 2003 server and all the setting on IIS are the same as the setting on
the Windows 2000 server. I worked on this problem for 4 days and still can't
make it to work.

Let me know if you need addtional information. Thank you in advance!

Daniel
noone

2005-06-28, 7:50 am

With out knowing the errors, I would guess that you might need to create an
Application mapping for .txt. IIS 6 is much tighter that IIS 5.

"Daniel" <Daniel@discussions.microsoft.com> wrote in message
news:47E19888-6872-40C7-AB1D-E4C0CF6E6671@microsoft.com...
> Hi all,
>
> I had a asp.net application that needs to access to a text file on the map
> drive. The application use an impersonate user account. Originally, this
> asp.net application runs on a Windows 2000 server and I don't have any
> problem accessing a file on the other Windows 2000 server. The share
> folder
> already mapped on the server that run the asp.net application.
>
> The problem is the asp.net can not access to the same map drive when I
> move
> the it to a Windows 2003 server. The impersonate user account on the
> Windows 2003 server and all the setting on IIS are the same as the setting
> on
> the Windows 2000 server. I worked on this problem for 4 days and still
> can't
> make it to work.
>
> Let me know if you need addtional information. Thank you in advance!
>
> Daniel



Daniel

2005-06-28, 5:54 pm

Hi Noone,

Thank you for your response! Actually there is no error, it just didn't let
me access to the text file on the map drive. Here is the code:
Try
bol = objFile.Exists(R://test.txt)
If bol Then
lblResponse.Text = "Access to " & txtPath.Text & " was
Granded!"
Else
lblResponse.Text = "Access to " & txtPath.Text & " was
denied!"
End If
Catch ex As Exception
lblResponse.Text = ex.ToString
End Try
the bol variable is return false even the test.txt is on the R drive. But
if I change to C:/test.txt the it return true. According to the
documentation, objFile.Exists is return false if it had no access to the
file. I believe it has something to do with impersonate on IIS 6. I had
this line on the Web.config <identity impersonate="true" />.

Could you please tell how to create an Application mapping for .txt?

Again, thank you for your help!

Daniel

"noone" wrote:

> With out knowing the errors, I would guess that you might need to create an
> Application mapping for .txt. IIS 6 is much tighter that IIS 5.
>
> "Daniel" <Daniel@discussions.microsoft.com> wrote in message
> news:47E19888-6872-40C7-AB1D-E4C0CF6E6671@microsoft.com...
>
>
>

Kristofer Gafvert [MVP]

2005-06-28, 5:54 pm

The documentation also says that it returns false if the file does not
exist.

I think that the file does not exist. You see, when you map a drive, it is
specific for your user account. The mapped drive does not exist for other
accounts. If this code is executed using some other account but the yours,
it will fail.

Have you tried to use an UNC path instead?

Anyway, this seems to be related to ASP.NET. Perhaps you want to try to
post to one of the ASP.NET newsgroups for a faster response.


--
Regards,
Kristofer Gafvert (IIS MVP)
www.gafvert.info - My Articles and help
www.ilopia.com


Daniel wrote:

> Hi Noone,
>
> Thank you for your response! Actually there is no error, it just didn't

let
> me access to the text file on the map drive. Here is the code:
> Try
> bol = objFile.Exists(R://test.txt)
> If bol Then
> lblResponse.Text = "Access to " & txtPath.Text & " was
> Granded!"
> Else
> lblResponse.Text = "Access to " & txtPath.Text & " was
> denied!"
> End If
> Catch ex As Exception
> lblResponse.Text = ex.ToString
> End Try
> the bol variable is return false even the test.txt is on the R drive.

But[vbcol=seagreen]
> if I change to C:/test.txt the it return true. According to the
> documentation, objFile.Exists is return false if it had no access to the
> file. I believe it has something to do with impersonate on IIS 6. I had
> this line on the Web.config <identity impersonate="true" />.
>
> Could you please tell how to create an Application mapping for .txt?
>
> Again, thank you for your help!
>
> Daniel
>
> "noone" wrote:
>
create an[vbcol=seagreen]
the map[vbcol=seagreen]
Originally, this[vbcol=seagreen]
any[vbcol=seagreen]
I[vbcol=seagreen]
the[vbcol=seagreen]
setting[vbcol=seagreen]
still[vbcol=seagreen]
Daniel

2005-06-28, 5:54 pm

Hi Kristofer,

Thank you for your response. The test.txt file is on the R drive. I
believe the problem is how to configure a certain user to execute the asp.net
from IIS 6. This application run fine on Windows 2000 server. It is about
the impersonate configure that allows a specific user to execute the
application.

Again, thank you for your response.

Daniel

"Kristofer Gafvert [MVP]" wrote:

> The documentation also says that it returns false if the file does not
> exist.
>
> I think that the file does not exist. You see, when you map a drive, it is
> specific for your user account. The mapped drive does not exist for other
> accounts. If this code is executed using some other account but the yours,
> it will fail.
>
> Have you tried to use an UNC path instead?
>
> Anyway, this seems to be related to ASP.NET. Perhaps you want to try to
> post to one of the ASP.NET newsgroups for a faster response.
>
>
> --
> Regards,
> Kristofer Gafvert (IIS MVP)
> www.gafvert.info - My Articles and help
> www.ilopia.com
>
>
> Daniel wrote:
>
> let
> But
> create an
> the map
> Originally, this
> any
> I
> the
> setting
> still
>

Kristofer Gafvert [MVP]

2005-06-30, 7:49 am

The file is on your account's R drive. But it is not available to the user
account used by ASP.NET. This is because when you map a drive, it is
specific to the account that is doing the mapping.

The best thing to do in these situations is to use UNC paths instead
(\\ServerName\Share\), because it is more robust, and will not fail as
easily.

My recommendation would still be to use UNC path, no matter if it worked
on Windows 2000 or not, or if you impersonate the user or not.

--
Regards,
Kristofer Gafvert (IIS MVP)
www.gafvert.info - My Articles and help
www.ilopia.com


Daniel wrote:

> Hi Kristofer,
>
> Thank you for your response. The test.txt file is on the R drive. I
> believe the problem is how to configure a certain user to execute the

asp.net
> from IIS 6. This application run fine on Windows 2000 server. It is

about[vbcol=seagreen]
> the impersonate configure that allows a specific user to execute the
> application.
>
> Again, thank you for your response.
>
> Daniel
>
> "Kristofer Gafvert [MVP]" wrote:
>
it is[vbcol=seagreen]
other[vbcol=seagreen]
yours,[vbcol=seagreen]
didn't[vbcol=seagreen]
was[vbcol=seagreen]
was[vbcol=seagreen]
the[vbcol=seagreen]
I had[vbcol=seagreen]
on[vbcol=seagreen]
have[vbcol=seagreen]
share[vbcol=seagreen]
when[vbcol=seagreen]
on[vbcol=seagreen]
the[vbcol=seagreen]
advance![vbcol=seagreen]
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com