2012-07-18 13 views
0

我正在使用LDAP查询可用域的列表。我的逻辑工作正常,当我在一台机器上运行一个nic卡可用,并且它成功查询域列表时,但是当我在有多个nic卡的机器上运行这个时,例如一个用于域A和另一个用于域B,我收到异常的原因很简单,即DirectoryEntry()绑定失败。查询可用域列表,环境中有两个不同域的多个NIC卡

我只需要为此使用LDAP提供程序。

下面是代码片断:

using (DirectoryEntry RootDSE = new DirectoryEntry("LDAP://rootDSE")) 
    { 
     // Retrieve the Configuration Naming Context from RootDSE 
     string configNC = RootDSE.Properties["configurationNamingContext"].Value.ToString(); 

     // Connect to the Configuration Naming Context 
     using (DirectoryEntry configSearchRoot = new DirectoryEntry("LDAP://" + configNC)) 
     { 
      // Search for all partitions where the NetBIOSName is set. 
      using (DirectorySearcher configSearch = new DirectorySearcher(configSearchRoot)) 
      { 
       configSearch.Filter = ("(NETBIOSName=*)"); 

       // Configure search to return dnsroot and ncname attributes 
       configSearch.PropertiesToLoad.Add("dnsroot"); 
       configSearch.PropertiesToLoad.Add("ncname"); 
       using (SearchResultCollection forestPartitionList = configSearch.FindAll()) 
       { 

回答

0

当使用LDAP无需服务器或域结合字符串,如LDAP://rootDSE,缺省域将是计算机加入到域。如果计算机未加入域,则绑定将失败(您还需要提供用户名和密码)。运行该应用程序的用户或网站/服务的线程或用户(如果在绑定期间指定了用户)必须能够读取目标域,否则绑定将失败。

如果这些都不能解决您的问题,那么您需要提供有关这两个域的更多信息。例如,他们是否在同一个森林里?

相关问题