We recently moved the web application to a new computer. The old one was Win2k, IIS 6.
New machine - Win Server 2003, IIS 7.
The application previously searched for image files on a network resource displayed as a drive letter O. It works great.
After moving, the application could no longer access these files. The part of the application that is trying to access the disk files O:is compiled by CGI, so I'm not sure what this looks like inside. I could access the source, but I decided to try a very simple test to try to see what happened first.
To try and troubleshoot, I created a small C # program that tries to access the test file locally (on disk C:), then searches for a file on disk O:, then disk Z:and then searches for the same file as on disk O:, but uses UNC way instead of relying on drive mapping. Finally, it prints out the domain and username in which it works. I registered this as CGI using the same method that was used to register the original EXE that was ported from the old server.
A file on disk C:is read without problems, but other files cannot be read. And the C # application tells me that it works as an account Washington$in a domain Traffic. The THUUGHT account was Washington(note that in the end there is $, and the other is not).
Immediately after I tried this and got crashes, I logged in via Remote Desktop as a user: Washingtonin the domain Trafficand was able to easily check the test file on the UNC command line path through dir \\trsystem\images2\testFile.txt.
I am not attached to the drive letters displayed; in fact, I would like to switch to using a UNC path.
Also, I'm pretty new to Windows domains and IIS management / administration. This problem can have a very basic root cause, which I simply do not know or do not notice.
:
--- Success opening C drive file! ---
Failed to open O drive file:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'O:\testFile.txt'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at Testing.Main()
Failed to open Z drive file:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\testFile.txt'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at Testing.Main()
Failed to open UNC file:
System.UnauthorizedAccessException: Access to the path '\\trsystem\images2\testFile.txt' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at Testing.Main()
---------- ---------- ----------
Domain Name is:TRAFFIC
UserName is:WASHINGTON$
( , # -, , , ):
using System;
using System.IO;
using System.Security.Permissions;
class Testing{
public static void Main() {
bool cFile = true;
bool oFile = true;
bool zFile = true;
bool uncFile = true;
try{
File.OpenRead("C:\\testFile.txt");
}
catch (Exception e){
Console.WriteLine("Failed to open C drive file:\n");
Console.WriteLine(e.ToString());
cFile = false;
}
if (cFile)
{
Console.WriteLine("\n\n--- Success opening C drive file! ---\n\n");
}
Console.WriteLine("\n\n");
try
{
File.OpenRead("O:\\testFile.txt");
}
catch (Exception f)
{
Console.WriteLine("Failed to open O drive file:\n");
Console.WriteLine(f.ToString());
oFile = false;
}
if (oFile)
{
Console.WriteLine("\n\n--- Success opening O drive file! ---\n\n");
}
Console.WriteLine("\n\n");
try
{
File.OpenRead("Z:\\testFile.txt");
}
catch (Exception g)
{
Console.WriteLine("Failed to open Z drive file:\n");
Console.WriteLine(g.ToString());
zFile = false;
}
if (zFile)
{
Console.WriteLine("\n\n--- Success opening Z drive file! ---\n\n");
}
Console.WriteLine("\n\n");
try
{
File.OpenRead("\\\\ntsys\\images2\\testFile.txt");
}
catch (Exception g)
{
Console.WriteLine("Failed to open UNC file:\n");
Console.WriteLine(g.ToString());
uncFile = false;
}
if (uncFile)
{
Console.WriteLine("\n\n--- Success opening UNC file! ---\n\n");
}
Console.WriteLine("\n\n");
Console.WriteLine("---------- ---------- ----------\n\n");
string domainName = Environment.UserDomainName;
string userName = Environment.UserName;
Console.WriteLine("Domain Name is:" + domainName + "\n");
Console.WriteLine("UserName is:" + userName + "\n\n");
}
}
!