Logon failure: unknown user name or bad password opening a networked file out of process
Microsoft .Net Framework 3.5
IIS/Web Server on Windows 2003 Server, file server on Windows 2000 Advanced Server
I have read several posts about this problem both here on this site as well as many articles on others, but it seems that the typical solutions aren't solving my problem. Basically, our developer has written some code to read a file from the network, but he gets an exception when attempting to access that file. The specific error is "Logon failure: unknown user name or bad password". The two servers (the web server and the file server) are both on the same domain and the same subnet. We are of course using a UNC path to reference the file share although our attempt at using a mapped drive didn't yield any better results.
I *think* my problem is that the impersonation isn't working despite having set the following in Web.Config:
<identity impersonate="true" userName="DOMAIN\user" password="password" />
I base that assumption on the fact that I know this user has permissions to read the file and I know the password is correct. I'm not sure if there is a way to prove that the impersonation is occurring however.
I don't know if the article at http://support.microsoft.com/kb/317012
applies since it is for ASP.Net 1.x, but the quote from it below concerns me:
"However, impersonation often does not work when you try to access remote resources unless the application uses an authentication mechanism that can be delegated, such as Kerberos or Basic authentication."
We are not using Kerberos or Basic authentication, the way I understand it. Instead, our application is using forms authentication as specified in Machine.config. We have tried turning anonymous access off on IIS and that did not resolve the issue. I have also turned on "Integrated Windows Authentication" in the Directory Security tab to no avail. The article at
seems to suggest that I may have to set up delegation, but it also specifies that in Web.Config, the authentication mode has to be "Windows". As I mentioned, we are using forms authentication and I don't believe that
can be changed, so even though I followed the other instructions, I still had the same behavior.
Any insight is much appreciated as always.
private DataCollection GetFileData(string file)
StreamReader sr = null;
ReportDataCollection dataCol = new ReportDataCollection();
sr = new StreamReader(file);
while (sr.Peek() != -1)
line = sr.ReadLine();
if (!string.IsNullOrEmpty(line) && !line.StartsWith("^^"))
data = new ReportData();
data.Line = line;
catch (Exception e)
if (sr != null) sr.Close();