我有一个以工作中的生产设置为模型的开发网络设置,当我在同一子网中时,我已经能够成功查询 Active Directory 并且可以解析服务器。现在,我正在尝试在需要远程访问终端服务器(这是唯一可访问 Internet 的服务器)的位置进行设置,并使用该连接来访问仅限内部的域控制器,然后我可以在其中运行我的查询(全部在 C# 中)。也许更好的解释方式是我试图将此 RDP 连接转换为某种网桥,当我创建我的LDAP 路径。
RDP 是正确的使用方法吗?我在代码项目中发现了这一点,但它似乎是为了设置远程桌面,而不是允许我访问内部 DC:
// RDP test
rdp.Server = "firewall";
rdp.UserName = "Administrator";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "mypassword";
rdp.Connect();
string moo2 = rdp.UserName;
string moo = rdp.ProductName;
rdp.Disconnect();
我的开发 TS 被称为“防火墙”,从那里我希望能够针对 DC 执行以下代码:
// Fire up the directory
DirectoryEntry ADRoot = new DirectoryEntry();
ADRoot.Username = "myusername";
ADRoot.Password = "mypassword";
ADRoot.Path = "LDAP://192.168.1.11";
// Search for all the computer objects
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = "(&ObjectCategory=computer)";
searcher.SearchRoot = ADRoot;
SearchResultCollection results = searcher.FindAll();
我完全赞成任何可以让我通过互联网访问这个内部 DC 的方法。