问题
I have two different sets of image files that reside in the root images directory of two different web sites on two different web servers. For arguments sake, let's say the first web server is called web1 and has a primary ip address of 111.111.111.111 and the second web server is called web2 and has a primary ip address of 111.111.111.112.
Now, I want to write a web application on web1 that reads the files from the first web site. I can easily do this using classes from the System.IO namespace. But how can I achieve this same functionality for the second web server. In other words, how can I programmatically access that directory via UNC and send in the domain user account credentials necessary to access the resources in that drive. For example, I would like to be able to write something like the following: Directory.GetFiles("\111.111.111.112\C$\inetpub\wwwroot\images", domain_user_name, domain_user_password). Ideally, I would like to accomplish this task without having to touch the impersonation settings within the web application or IIS.
Anyone has any ideas?
回答1:
The default ASP.NET account is a local account and has no network privileges.
You could try doing the impersonation in code. See: http://support.microsoft.com/default.aspx?scid=KB;EN-US;306158
来源:https://stackoverflow.com/questions/570944/accessing-a-unc-drive-in-asp-net