Solved

Logon failure: unknown user name or bad password opening a networked file out of process

Posted on 2009-05-08
3
2,472 Views
Last Modified: 2013-11-08
Logon failure: unknown user name or bad password opening a networked file out of process

IIS 6.0
ASP.Net 2.0.50727
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
http://support.microsoft.com/default.aspx?scid=kb;en-us;810572 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;

        ReportData data;

        ReportDataCollection dataCol = new ReportDataCollection();

        try

        {

            sr = new StreamReader(file);

            while (sr.Peek() != -1)

            {

                line = sr.ReadLine();

                if (!string.IsNullOrEmpty(line) && !line.StartsWith("^^"))

                {

                    data = new ReportData();

                    data.Line = line;

                    dataCol.Add(data);

                }

            }
 

        }

        catch (Exception e)

        {

            throw e;

        }

        finally

        {

            if (sr != null) sr.Close();

        }
 

        return dataCol;

}

Open in new window

0
Comment
Question by:izgoblin
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24335840
0
 

Author Comment

by:izgoblin
ID: 24337716
Thank you!  I just spoke to my developer and he was able to use the links you provided to branch off and read more about impersonating a user directly in his code.  Once he did so, he was able to read from and write to the network.  
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24338614
I am glad your problem is solved.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now