Как насчет этого
<DllImport("advapi32.dll")> _
Public Shared Function LogonUser(lpszUsername As String, lpszDomain As String, lpszPassword As String, dwLogonType As Integer, dwLogonProvider As Integer, phToken As IntPtr) As Boolean
End Function
<DllImport("kernel32.dll")> _
Public Shared Function CloseHandle(hObject As IntPtr) As Boolean
End Function
Public Shared Function OpenFileWithAccount(filename As String, username As String, domain As String, password As String) As Stream
Dim token As IntPtr
If Not LogonUser(username, domain, password, 2, 0, token) Then
Throw New Win32Exception()
End If
Try
Using WindowsIdentity.Impersonate(token)
Return File.OpenRead(filename)
End Using
Finally
CloseHandle(token)
End Try
End Function
и звоните
Dim stream as Stream
stream = OpenFileWithAccount("filePath","userName","prod","password")