DirectoryInfo on read-only paths

G

Guest

Greetings everyone!

I am creating a webcontrol that reads one or more directorie's content and
displays all the filenames (tipically PDFs or PPTs) so that the user can
select the desired one and see the content. We call it FileBrowser (oh so
clever)

The purpose of this control is to display security bulletins, tutorials,
user manuals on a corporate Intranet. So far so good.

Now. All this content is stored on a read-only location (as it is read-only
material), but it seems that DirectoryInfo does not work if Read/Write
premissions are NOT applied on the source directory.

The problem is that we cannot assign Everyone write permissions.

Does anyone know a workaround to this problem?
Is this actually true? (that we need read/write permissions)
 
G

Gopal \(FMS, Inc.\)

You can use impersonation to simulate windows authentication. This might
work for you if you do need read/write permissions to read directory info.
Add a node similar to the following in your web.config.
<configuration>
<location path="Default.aspx">
<system.web>
<identity impersonate="true" userName="<domain\user>"
password="<password>" />
</system.web>
</location>
</configuration>
I am not sure whether you do or do not need read/write permissions to read
directory info though.
Hope this helps you.

--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>
 
G

Guest

Ok. I found out about a couple of things:

I am using impersonation. Our standards porhibit the use of anonymous users,
so the application impersonates with the current connected user (it's a web
application)

You do not need read/write permissions. Not for read only methods at least.
So far so good.

Another thing I found out is that there's something to do with the .NET
Framework's permissions. If I try to access a directory using UNC paths on
the SAME computer, everything works, EVEN if I have read only access. The
second I try to access a resource outside the web server, I recieve an
UnauthorizedAccessException.

I read somewhere, that I could configure security for the framework in the
configuration console. But things that I've tried led nowhere.

Thanks everyone.
 
G

Guest

Gopal for Patrice:
This is the Exception thrown:

System.UnauthorizedAccessException: Access to the path
"\ARFPS01\......\Intranet_Docs\Co" is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalGetFileDirectoryNames(String fullPath, String
userPath, Boolean file)
at System.IO.Directory.InternalGetFiles(String path, String userPath, String
searchPattern) at System.IO.DirectoryInfo.GetFiles(String searchPattern)
at System.IO.DirectoryInfo.GetFiles()
at Arcadia.UI.WebControls.FileBrowser.BuildFileBrowser(String directory) in
\\ARDEV01\..........\webcontrols\filebrowser.cs:line 559

Chek my reply to Gopal for more data.
Note that the resource (directory) that I'm trying to browse is located on
our FP Server and not on our Web (DEV) server. I think the problem is around
that issue and the Framework's permission to access resources over the
network.

Any thoughts?
Thank you
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top