Access Denied in CreateDirectory with UNC Path
-
Hello together, I have a part in my web project for managing documents. If I upload a file and create the directory for store in with:
System.IO.Directory.CreateDirectory(strPathName)
it works fine with normal local path like "C:\temp\document". But if the path is a UNC-Path, I get an access denied exception. It does not matter that the UNC-Path is a local path like "\\localhost\Share" or to another computer. I try to use the impersonate feature in web.config:<identity impersonate="true" />
In this case normally ASPNET user is used by IIS and I have set full control access rights for this user to C:\temp directory and all sub dirs. Result: Get access denied exception Than I set user and pass:<identity impersonate="true" userName="domain/user" password="xyz" />
I get access denied too. Last chance was an idea from a guy found in a blog: http://blogs.msdn.com/saurabhkv/archive/2008/05/29/windowsidentity-impersonation-using-c-code.aspx The function runs without an error, but it solves not my problem. I get access denied too. What can I do?\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
Hello together, I have a part in my web project for managing documents. If I upload a file and create the directory for store in with:
System.IO.Directory.CreateDirectory(strPathName)
it works fine with normal local path like "C:\temp\document". But if the path is a UNC-Path, I get an access denied exception. It does not matter that the UNC-Path is a local path like "\\localhost\Share" or to another computer. I try to use the impersonate feature in web.config:<identity impersonate="true" />
In this case normally ASPNET user is used by IIS and I have set full control access rights for this user to C:\temp directory and all sub dirs. Result: Get access denied exception Than I set user and pass:<identity impersonate="true" userName="domain/user" password="xyz" />
I get access denied too. Last chance was an idea from a guy found in a blog: http://blogs.msdn.com/saurabhkv/archive/2008/05/29/windowsidentity-impersonation-using-c-code.aspx The function runs without an error, but it solves not my problem. I get access denied too. What can I do?\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)Why on earth would you write a website that tries to create directories over a network ? You should always use Server.MapPath for any System.IO methods, and obviously, they are going to map to local paths.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Why on earth would you write a website that tries to create directories over a network ? You should always use Server.MapPath for any System.IO methods, and obviously, they are going to map to local paths.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Why on earth, somebody must ask, WHY something must be so as written :( I have my reasons and please note: I'm note the only one with this problem. There are many many pages in the web with this problem and nobody can help. So. BTT The reason is: If you want store documents and I have a web farm, each web server instance need access to each document. Therefore only on web server in the web farm have direct local access to the documents. Each other web server via UNC-Path. The alternative is a copy of each document local inside each web server. That is not acceptable by me, my company and our customers.
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)