I have inherited this old WebForms site that I am attempting to migrate to Windows Server 2022 on VMWare because the server it is currently running on is being retired.
The web site has links to a bunch of documents which I can get working if I set up a virtual directory so long as the documents are on the same machine as the web site. However, this is not what I want. We have a corporate domain with a DFS where the documents live that I am trying to access, unsuccessfully.
I am using Specific User Authentication with a domain user account that has permissions to access the location in question granted but when I click one of the links I get an error page with the following information.
Config Error Cannot read configuration file due to insufficient permissions
Config File \?\UNC\Servername.Domain.com\SomeFolder\web.config
What exactly is going on here and how do I get this working?
The web site is running in the DefaultAppPool using ApplicationPoolIdentity and Anonymous Authentication.
Does this mean that the user account I am using for the Specific User Authentication needs to have access to the web.config file on the machine that is hosting the documents I am trying to access?
Do I need to change the user of DefaultAppPool from ApplicationPoolIdentity to something else? Should I be using pass-through authentication instead of specific user?
Also, in the source code, which is written in VB.NET, the original developer has a function that returns a Generic.List(Of Document) where Document is a simple class with a few properties, one of which being the URL for the document. The function, stripped of much of the irrelevant code looks something like:
Public Shared Function GetDocumentByType(ByVal DocumentType As String, ByVal SearchTxt As String) As Generic.List(Of Document)
Dim fs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
Dim FileLoc As String
Dim FileUrl As String
Dim docList as New Generic.List(Of Document)()
Select Case DocumentType
Case "Some Type"
FileLoc = "C:\SomePath\SomeOtherPath"
FileUrl = "/VirtualDirectory/SomeOtherPath"
' Bunch of other cases here
Case Else
Return Nothing
End Select
Try
fs = FileIO.FileSystem.GetFiles(FileLoc)
For Each f1 As String in fs
If InStr(f1, SearchTxt) Then
FileName = Right$(f1, (Len(f1) + 1 - InStr(f1, SearchTxt)))
NextDocument = New Document(DocumentType, FileUrl & FileName)
list.Add(NextDocument)
End If
Catch e As Exception
'Exception code here
End Try
Return docList
End Function
Which iterates through the files in FileLoc for a given DocumentType looking for files with SearchTxt in their names and adding a new Document for each of them to the returned List(Of Document). The FileUrl is the virtual directory which resides on the same machine, and the FileLoc is the Physical Path which is also on the same machine. In the example of the above code the virtual directory would be pointing to "C:\SomePath" Now what I would like to know is, is this the best way of going about this, and if I get access to the DFS then can I just use the UNC for FileLoc and use FileIO.FileSystem.GetFiles(FileLoc) ?