Testing the UNC Accessibility Path

My program requires access to a specific UNC path, but the path is cross-domain, so depending on which machine the program is running on, it may or may not have default credentials. Typically, the user simply needs to open the explorer and enter the UNC address or IP address to receive an invitation to enter the system (after which they can enter the appropriate credentials for the domain in which the shared resource is located).

Is there a “clean” way to check for UNC availability, and if the Windows credentials are bad by default, then suggest them for different ones?

Right now I'm using some kind of nasty code to try to read a text file on a shared resource, catch an IOException and then open the process object "explorer.exe" (hidden) to get a login prompt. All this is contained in a loop that checks again after 10 seconds. This is kind of work, but solution and logic seem really undesirable.

Is my only choice really WNetUseConnection or an interop-style solution?

+5
source share
2 answers

Check out these articles:

:

new FileIOPermission(FileIOPermissionAccess.Read, path).Demand();

SecurityException, , UNC FileIOPermission.Demand() no-op.

+3

, , , (ACL) NTFS.

- # "Access Control List" , . , , .

0

All Articles