简体   繁体   English

Windows域中的网络共享

[英]Network shares in a Windows Domain

I have two computers in a Windows Domain. 我在Windows域中有两台计算机。
One of them runs an application that accesses network shares on the other, as it is authorized via a Domain account. 其中一个运行通过域帐户授权的访问另一个网络共享的应用程序。 However, in a freshly booted configuration, the access on the shares fails. 但是,在新启动的配置中,共享上的访问失败。
The user workaround is to click the share in Windows Explorer and from that time on, it is accessible by the application. 用户的解决方法是单击Windows资源管理器中的共享,从那时起,应用程序便可以对其进行访问。
The Windows Command Prompt ( cmd ) has the same problem: dir s: (s being the shared drive letter) fails until you click the drive in Explorer. Windows命令提示符( cmd )具有相同的问题: dir s: (s是共享驱动器号)失败,直到您在Explorer中单击驱动器。
Is there any system call I can invoke to " open " the network share programatically from my application, rather than clicking it in Explorer? 我可以调用任何系统调用来以编程方式从应用程序“ 打开 ”网络共享,而不是在资源管理器中单击它吗?
Thx 谢谢

connecting and reconnecting a network share is somewhat tricky, windows sometimes misses to restore connections from laptops roaming from one net to another. 连接和重新连接网络共享有些棘手,Windows有时无法恢复从漫游到一个网络的笔记本电脑的连接。

I use this little strategy in some of my BAT files... 我在一些BAT文件中使用了这种小策略...

IF NOT EXIST s:\NUL (
   NET USE s: /D
   NET USE s: \\computername\sharename
)

if the current user name exists and have the same password in the domain or in the server, or if the client domain is in the trust list of the domain controller, access is allowed. 如果当前用户名存在并且在域或服务器中具有相同的密码,或者如果客户端域在域控制器的信任列表中,则允许访问。 If not, you will need to specify the username in the command and will be prompted for the password (specifying the password in the BAT file is a very bad idea) 如果不是,则需要在命令中指定用户名,并提示输入密码(在BAT文件中指定密码是一个非常糟糕的主意)

NET USE s: \\computername\sharename /USER:username *

see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true for more information 有关更多信息,请参见http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true

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

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