managed way of accessing UNC path with authenticaton
Using .net >= 4, is there a way to access UNC path with authentication (without using Win32 API)? Basically for a given folder path, i want to get its directory listing and load file content.
I found a 6 year old solution with Win32 API Accessing a Shared File (UNC) From a Remote, Non-Trusted Domain With Credentials Is there a modern solution?
The .NET way of doing this is through impersionation. Here are some links to get you started:
How do you do Impersonation in .NET?
http://blogs.msdn.com/b/shawnfa/archive/2005/03/22/400749.aspx
If it is sufficient to impersonate the current user, you can simply use:
using(WindowsIdentity.GetCurrent().Impersonate())
{
// Within this block you can access the UNC share
}
链接地址: http://www.djcxy.com/p/44178.html
上一篇: 如何在UWP应用程序中使用运行IoT Core的Raspberry Pi访问网络共享
下一篇: 通过身份验证访问UNC路径