CreateDirectory on a Shared Server ISP

G

Guest

When trying to use the function CreateDirectory on my local machine
everything works fine but when I upload the page to my webhost I get an issue
that it can't find path on D:\, though D:\ is what my website is found on.
This is an H-SPHERE web cluster host.

From my research I found that this issue is due to ASPNET account not having
read previdgeles on the root of the drive.

My question is what is the correct approach to solve this issue. Should the
ISP grant read access to the root and all uplevel folders that my application
is under?

Should I have to use PInvoke to call an unmanaged CreateDirectory from
Kernel32? If so what if ISP does not allow calling unmanaged code?

I cannot believe this was overlooked when the framework was being developed
or that there is no known fix.

A related post can be found at:
http://msdn.microsoft.com/newsgroup...n-us&mid=f84e99c8-b8f0-4e22-812d-f880995ed65f

Thanks,

Dan
 
S

Scott Allen

Hi Dan:

See comments inline.

When trying to use the function CreateDirectory on my local machine
everything works fine but when I upload the page to my webhost I get an issue
that it can't find path on D:\, though D:\ is what my website is found on.
This is an H-SPHERE web cluster host.

From my research I found that this issue is due to ASPNET account not having
read previdgeles on the root of the drive.

I think you'll need write privs, not just read privs.
My question is what is the correct approach to solve this issue. Should the
ISP grant read access to the root and all uplevel folders that my application
is under?

I assume this is a shared hosting environment? If I was the ISP I
would not want to grant write privs on the root of a drive. If you
software has a bug or is comprimised it could damage the folders
belonging to other customer's and ruin my reputation. I'd have no
problem giving you write privs to just your folders.
Should I have to use PInvoke to call an unmanaged CreateDirectory from
Kernel32? If so what if ISP does not allow calling unmanaged code?

You'll face the same permissions issue. The framework ultimately calls
Win32 API functions to perform the work.
I cannot believe this was overlooked when the framework was being developed
or that there is no known fix.

I'm glad there is no 'fix' as I really don't see a problem. You just
can't hand out control of the machine in a shared hosting enviornment.
 
G

Guest

Scott, thanks for the reply. I agree that you really shouldn't share the
drive root. But unfortunately the way the CreateDirectory function is
implemented it has to be in order to do a simple creation of a directory
under your shared folder, which is a must.

This was really a poor design.

The CreateDirectory function should not have to see the root of the drive,
it should only have to start from the current directory to see if it can
create a sub-directory. To get around this issue, I could use the
CreateDirectory function from "kernel32" or _mkdir from msvcrt and I could
get around it, but again if the ISP doesn't allow calls to unmanaged code
you're pretty much up the creek without a paddle.

I ran into this issue with trying to deploy a DotNetNuke portal website.
http://www.dotnetnuke.com
 
G

Guest

Just to thorough, the actual directory of the website could be
D:\hshome\username\urlname.

In the case of my ISP, users have full rights to everything under username.
So we should be able to create directories on the fly using
Directory.CreateDirectory, but because ASPNET does not have read access to
D:\, or hshomes; it fails. Where as CreateDirectory of "kernel32" does not
need read access to D:\ or hshomes. But again, if ISP doesn't allow calls to
unmanaged code you're done for.
 
S

Scott Allen

Opps!

You are absolutely right, Dan. Apologies for my misunderstanding. Let
me experiment a bit and get back to you...
 
S

Scott Allen

Interesting - I'm able to use CreateDirectory even though my NETWORK
SERVICE account has no permissions in the root of the drive. I'll
admit this sequence of calls has some problems - but it appears to
succeed. What am I missing?

The sequence in FileMon looks like:

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION E:\dev ACCESS DENIED
Attributes: Error

9:18:36 PM w3wp.exe:3428 OPEN E:\ ACCESS DENIED NT
AUTHORITY\NETWORK SERVICE

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION E:\dev\xprmnt ACCESS
DENIED Attributes: Error

9:18:36 PM w3wp.exe:3428 OPEN E:\dev\ ACCESS DENIED NT
AUTHORITY\NETWORK SERVICE

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION E:\dev\xprmnt\aspnet
SUCCESS Attributes: D

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION
E:\dev\xprmnt\aspnet\createdir SUCCESS Attributes: D

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION
E:\dev\xprmnt\aspnet\createdir\foo FILE NOT FOUND Attributes: Error

9:18:36 PM w3wp.exe:3428 QUERY INFORMATION E:\ ACCESS DENIED
Attributes: Error

9:18:36 PM w3wp.exe:3428 CREATE E:\dev NAME COLLISION Options:
Create Directory Access: All

9:18:36 PM w3wp.exe:3428 CREATE E:\dev\xprmnt NAME COLLISION
Options: Create Directory Access: All

9:18:36 PM w3wp.exe:3428 CREATE E:\dev\xprmnt\aspnet\createdir\foo
SUCCESS Options: Create Directory Access: All

9:18:36 PM w3wp.exe:3428 CLOSE E:\dev\xprmnt\aspnet\createdir\foo
SUCCESS
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top