Access to a windows share through UNC path, before the session opening

陌路散爱 提交于 2020-01-06 14:18:11

问题


I've to do a windows service which starts before the user logon. It's also mean that this service has to do have its own username/password. So how can I open a network share remotly without being logged?

I'm in a windows domain, and the goal is to use some configured credentials to access the remote files I need.

Do you have an idea? I just can't find anything to access easily to the server

Edit: I'm sorry I made a mistake, the client computer isn't in the domain, the server is :(


回答1:


If you can't run the service as the user in question, you can do it through code with P/Invokes.

Connect to network drive with user name and password




回答2:


Generally what you would do is set the service to run under a named user (domain) account and give that user access to the remote share. Then access the files on that share as you would any other i.e.

File.ReadAllText(@"\\SomeMachine\SomeShare\Something.txt");


来源:https://stackoverflow.com/questions/7011655/access-to-a-windows-share-through-unc-path-before-the-session-opening

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!