开发者

Access a shared folder(which is protected)

开发者 https://www.devze.com 2023-02-03 12:29 出处:网络
I need help in writing a C# script which can access a secured shared location(i hv the username and password) in or开发者_C百科der to access some files from that location and also dump some files over

I need help in writing a C# script which can access a secured shared location(i hv the username and password) in or开发者_C百科der to access some files from that location and also dump some files over there pragmatically. Thank you in advance


To access a network share that is protected you need to call LogonUser and do impersonation within your application. The MSDN article provides a code sample. Then you can just browse, copy/move, etc with the System.IO namespace. For instance:

System.IO.Directory.GetFolders(@"\\Server\Share");

will return a list of the folders on the network share.


I take it the app will be running under credentials different than the username/password that can access the folder.

You can use impersonation, see this question for how to set up the win32 api calls to logon and revert to self.

Impersonate user in codebehind

0

精彩评论

暂无评论...
验证码 换一张
取 消