2010-07-07 106 views
1

嘗試枚舉LDAP(輕量級目錄訪問協議)中的用戶時出現以下錯誤。我已驗證我的連接字符串到服務器(LDAP://域名)。服務器當然是在線和可操作的。枚舉LDAP中的用戶時出錯

錯誤消息:服務器是不可操作
堆棧跟蹤

[2264] System.Transactions Critical: 0 : 
[2264] <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>DefaultDomain</AppDomain><Exception><ExceptionType>System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The server is not operational. 
[2264] </Message><StackTrace> 
[2264] Server stack trace: 
[2264] at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) 
[2264] at System.DirectoryServices.DirectoryEntry.Bind() 
[2264] at System.DirectoryServices.DirectoryEntry.get_AdsObject() 
[2264] at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) 

更新 - 添加的代碼

DirectoryEntry dirEntry = new DirectoryEntry("_LDAP://DOMAINNAME", "userName", "password"); 
System.DirectoryServices.DirectorySearcher dirSearcher = new System.DirectoryServices.DirectorySearcher(dirEntry); 
     try 
     { 
      foreach (SearchResult resEnt in dirSearcher.FindAll()) 
      { 
       DirectoryEntry de=resEnt.GetDirectoryEntry(); 
       foreach (string propname in de.Properties.PropertyNames) 
       { 
        //Add to the datatable 
       } 
      } 
     } 
     catch (Exception ex1) 
     { 
      //Log exception 
     } 
     finally 
     { 
      dirEntry.Dispose(); 
      dirSearcher.Dispose(); 
     } 

爲什麼這厚望可能發生將是非常有什麼想法升值呢?

由於提前,
巴拉斯ķ

+0

你能告訴我們你的代碼用於枚舉用戶嗎?你正在使用什麼LDAP路徑? – 2010-07-07 08:15:06

+0

已添加用於枚舉用戶的代碼。還驗證了服務器存在... – 2010-07-07 10:58:57

回答

0

發現,對於這種情況的原因是,我用的域名短名稱,而不是全名。正確的格式是

DirectoryEntry dirEntry = new DirectoryEntry("LDAP://DOMAINFULLNAME", "userName", "password");