System.IO.FileNotFoundException:找不到找不到网络路径。除了在使用DirectoryEntry对象在Windows 7找不到、路径、对象、网络

2023-09-05 04:13:14 作者:ぃMissnざ°唯美

我试图通过使用DirectoryEntry对象连接到远程Windows 7计算机。这里是我的code

i am trying to connect to remote windows 7 machine by using DirectoryEntry object. here is my code

DirectoryEntry obDirEntry = new DirectoryEntry("WinNT://hostName", "hostName\\testUser", "password123", AuthenticationTypes.Secure);               
            try
            {
                if (obDirEntry.Properties.Count > 0)
                {                        
                   //ok
                }
            }
            catch (Exception excp)
            {}

如果我能够连接到远程Windows Server 2003的计算机或本地Windows 7计算机,然后我没有得到任何错误。但是,当我试图连接到远程的Windows 7机器,然后我得到异常的行如果(obDirEntry.Properties.Count> 0)

if i am able to connect to remote windows server 2003 machine or local windows 7 machine , then i didn't get any error. But when i am trying to connect to remote windows 7 machine then i gets exception at line if (obDirEntry.Properties.Count > 0)

 Exception :System.IO.FileNotFoundException: The network path was not found.

 at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()
 at System.DirectoryServices.DirectoryEntry.RefreshCache()
 at System.DirectoryServices.DirectoryEntry.FillCache(String propertyName)
 at System.DirectoryServices.PropertyCollection.get_Count()

我能够ping远程Windows 7的M / C。防火墙和UAC也关闭。问题是我在每个远程Windows 7计算机得到这个问题。我试图把IP联系地址的网址,而不是主机名,但在这种情况下,即使在本​​地机器上,我得到上面的异常。 nslookup命令能够解决远程M / C主机名。 什么可能是原因?有什么可以为这种可能的解决方案? 提前致谢 !!

I am able to ping that remote windows 7 m/c. firewall and UAC is also off. Problem is i am getting this problem on each remote windows 7 machine. I have tried to put ip adress in url instead of hostname, but in that case even on local machine i get above exception. nslookup command is able to resolve that remote m/c hostName. What may be reason for this ? What can be possible solution for this ? Thanks in advance !!

推荐答案

您需要正确地访问远程注册表才能连接到Windows 7(和8)。以这种方式系统

You need proper access to the remote registry to be able to connect to Windows 7 (&8) systems in this manner.

有一个指导这里关于如何成功地连接到远程注册表。它收集所需的所有不同的信息 - 启用文件和打印机共享,启用远程注册表服务,并补充说,正在连接到远程注册表到 HKLM \系统\ CurrentControlSet \控制\ SecurePipeServers \ WinReg项的特定用户

There is a guide here on how to successfully connect to the remote registry. It gathers all the disparate information needed - enabling file and printer sharing, enabling the remote registry service and adding the specific user that is connecting to the remote registry into the HKLM\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg.

在所有这些任务都在远程系统上执行了,你应该能够使用远程连接到它的WinRT:// REMOTEHOST 。我测试了它在某些系统上我已经和它的作品。

Once all these tasks have been performed on the remote system, you should be able to connect remotely to it using WinRT://remoteHost. I tested it on some systems I had and it works.

这是很可能所有的工作,如果自动系统是一个域的约束制度和帐户被用来连接是一个域管理员联系帐户。

This is would probably all work automatically if the system was a domain bound system and the account being used to connect was a domain adminstrator account.