Search code examples
asp.netshared-directorywindows-security

ASP.Net unable to see shared folder


I've written a new application in a network I haven't worked in before, and am running into a problem.

If I have the following C# code:

FileStream fs = File.Create(@"\\MyServer\MyShare\testing.txt");
fs.Close();

In a console application, this code executes correctly.

In an ASP.Net application, I receive this error: Logon failure: unknown user name or bad password.

In the ASP.Net application, if I add in identity impersonate="true", I get this error: Access to the path '\MyServer\MyShare\testing.txt' is denied.

I've never ran into that logon failure message before; where is this coming from? If I create an application on the server and have it write to the phsyical location, it works fine (so security there is good), it just seems as though the security to the share is not working (even though it has 'Everyone' set to full writes), or there is something missing at the server level in which I'm not allowed to view anything in general.

Does anyone know what I'm missing here? I've written other applications that did similar things and have never run into this problem

Thanks!


Solution

  • Update:

    So I think I posted this too soon... The reason it was failing on my localhost was due to the directory being set as allow anonymous access (so the page wasn't impersonating; the user was '').

    It also started working on the server as well; however, nothing was changed there... I don't know if something was triggered during the app's downtime/shutdown or what, but everything's working as expected.

    Thanks for the comments!