Accessing a password protected file.
Hi;
Note: While our specific use is ASP.NET, this is a general "reading a file" question.
Our ASP.NET application allows a user to give it an XML filename and the app then opens that file as a datasource to generate a report. The issue we face is we donot want the file opened using the credentials of the user that our ASP.NET app is running under for two reasons:
- The ASP.NET user may not have access to\\hr\payroll\salaries.xml but the person requesting the report does.
- The ASP.NET does have access to Web.Config but the person requesting the report does not.
Our app supports both forms and WindowsIdentity as an authtication/authorization method. So we do not have the client identity to use if they are using the forms system.
For http(s) and ftp this is a piece of cake - we create a NetworkCredential and pass that to the Resolver for XmlDocument when doing it's load. Problem solved there.
But how do we handle files that are local to the server, on a network drive on the server, or on a\\server\share accessable from the server? And in all of those cases, the username/password to access the file could be a domain user or could be a user that exists only on the local machine - and that machine is remote from the ASP.NET server. Or it could be a user on another domain and that domain does not have a trust relationship with the domain our app is running on. Or the file could be available to "Everyone" which means with no credentials it can be read.
And with the way our system is structured, whatever file/credentials are setup, there will be multiple simultaneous requests to access the same data using the same credentials. So we cannot use the NetUseAdd call because it will fail if a connaction to that\\server\share already exists.
We can handle the case where it is a domain user on our domain used to access the file using impersonation. But the other cases appear to have no solution.
Help!!!!!
thanks - dave

