CreateDirectory working inconsistantly from ASP.net

From: David Davies (DavidDavies_at_discussions.microsoft.com)
Date: 10/25/04


Date: Sun, 24 Oct 2004 20:51:02 -0700

Please HELP !!

I have a web page that is trying to create folders on a file server

  eg. \\SERVERNAME\F4\Projects\[New Folder Name]

Users of the web site are authenticated with Windows Integrated Security.

(have tried on W2003/IIS6 and W2k/IIS5 with no difference in behavoir)

When a user connects to the using a browser on the same machine as the
webserver the code works and is able to create the new folder.

When the same user connects from a remote machine the CreateDirectory
function generates the following Exception
System.UnauthorizedAccessException
"Access to the path \"TEST\" is denied."
Source "mscorlib"
StackTrace
System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String
path)\r\n
...

I have tried to do this in 3 ways all with the same problem;
A)
DirectoryInfo di = Directory.CreateDirectory(newfullpath);

B)
DirectoryInfo root = new DirectoryInfo(rootPath);
DirectoryInfo di = root.CreateSubdirectory(folderName);

C)
[DllImport("kernel32.dll")]
static extern bool CreateDirectory(string lpPathName, IntPtr
lpSecurityAttributes);
...
bool result = CreateDirectory(path, IntPtr.Zero);
DirectoryInfo di = DirectoryInfo(path);

I have also checked that the Integrated Authentication is getting passed
correcty into the application

string origID = Thread.CurrentPrincipal.Identity.Name;
string contextUser = HttpContext.Current.User.Identity.Name;

Both call return the same user regardless if the call is from the server or
a remote machine.
Needless to say that the User has the required permissions to create the
folder because they are able to do so as long as they do it from a browser on
the server itself.

If anyone can shed any light on what is going on here I would greatly
appreciate it.

Regards,
David Davies
Goldman Sachs



Relevant Pages

  • CreateDirectory working inconsistantly from ASP.net
    ... I have a web page that is trying to create folders on a file server ... webserver the code works and is able to create the new folder. ... System.IO.__Error.WinIOError(Int32 errorCode, String str) ... DirectoryInfo di = Directory.CreateDirectory; ...
    (microsoft.public.dotnet.framework.aspnet)
  • CreateDirectory working inconsistantly from ASP.net
    ... I have a web page that is trying to create folders on a file server ... webserver the code works and is able to create the new folder. ... System.IO.__Error.WinIOError(Int32 errorCode, String str) ... DirectoryInfo di = Directory.CreateDirectory; ...
    (microsoft.public.dotnet.general)
  • Re: Checking to see of a folder exists
    ... Private Declare Function PathIsUNCServer Lib "shlwapi" _ ... Public Function IsUNCPathAServer(ByVal sPath As String) As Boolean ... wrong False value if path to be checked consists of only the server name. ... The folder doesn't exist on an existing server. ...
    (microsoft.public.excel.programming)
  • setting Username&password while using DirectoryInfo()
    ... particular folder on a server. ... For this I am using DirectoryInfo in the following way. ... this works fine when the server doesnt have a password set on the ... at System.IO.Directory.InternalGetFileDirectoryNames(..blah blah blah) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Moving mail items based on Subject text
    ... a shared folder based upon the Subject field containing a specific text ... The items concerned are emails identified as spam by our server-based ... the text string in the subject field and moves spam items to a separate Spam ... shared mail folders on the server? ...
    (microsoft.public.exchange.admin)