Hi I am writing a WPF app that needs to access my files on another PC on my network (domain). My first try to access a remote folder has not been a raging success.
On my Windows 7 laptop I entered in Windows Explorer
\\WIN-DCname\c$
, this is the path to C drive on my test domain controller, and when challenged I logged in with the administrator account for the DC. I can then access the folder tree of C drive as expected.
As a test application I used the following to probe that same drive:
Try
Dim DirInfo As New DirectoryInfo("\\WIN-DCname\c$")
Dim Dirs = DirInfo.GetDirectories.OrderByDescending(Function(x) x.FullName)
Catch ex As Exception
End Try
but the GetDirectories line throws an exception:
The system detected a possible attempt to compromise security. Please
ensure that you can contact the server that authenticated you.
I’m starting to think there is a permissions problem here…. Do I have to programmatically authenticate again prior to doing this? If so how?
Or is it not possible to do a GetDirectories over the network? Is there another way?
Thanks for any advice!
In the end it turns out that I needed to use Impersonation, which lets me programmatically emulate another user while executing a block of code. No opening of ports was required.