A problem to be solved in recent work is to allow ASP. NET to access the network disk, read the PDF file and open it in the browser.
At first, I thought it was very simple, that is, to directly map the network hard disk and then directly call directory. the getfiles function has a problem. As a result, it takes several days because the getfiles function cannot return a value because of ASP. net is not authorized to access the network disk. in this way, only impersonate can be used. However, if impersonate is used again, an error is always reported and the expected result cannot be obtained.
Baidu, Google, failed, and finally gathered various directors to solve the problem.
Assume that the server where the webpage is located is websvr, and the server where the network disk is located is filesvr.
1. Create a new user on filesvr that can access the network disk. Assume the user is test and the password is 1234.
2. Similarly, to create an identical user test on websvr, the password should be exactly the same, which is 1234 (Note: if there is a letter, it is obvious that the password should be the same)
3. the rest is simple, and ASP is used directly. net impersonate, in the web. add <identity impersonate = "true" username = "test" Password = "1234"/>
The only difference is that username & password is exposed in plain text. Of course, the user/pwd is not an important system administrator, and the result is acceptable.
However, the test results only pass the network file path in UNC format. It still does not work for ing Network hard disks. However, this result can only be accepted first.