简体   繁体   English

在 session 打开之前,通过 UNC 路径访问 windows 共享

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

I've to do a windows service which starts before the user logon.我必须在用户登录之前启动 windows 服务。 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.我在一个 windows 域中,目标是使用一些配置的凭据来访问我需要的远程文件。

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:(编辑:对不起,我犯了一个错误,客户端计算机不在域中,服务器是:(

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 ie然后像访问其他任何文件一样访问该共享上的文件,即

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

If you can't run the service as the user in question, you can do it through code with P/Invokes.如果您不能以相关用户的身份运行服务,您可以通过带有 P/Invokes 的代码来完成。

Connect to network drive with user name and password 使用用户名和密码连接到网络驱动器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM