2012-11-20 36 views
0

我正在嘗試使用c#查找Exchange Server 2007的所有會議室。我發現了一個簡單的方法,通過使用EWS託管API來做到這一點:用於檢索Exchange 2007的房間列表的LDAP問題

http://msdn.microsoft.com/en-us/library/exchange/hh532566(v=exchg.80).aspx

不幸的是,GetRoomLists()不爲Exchange Server,如果一些已經工作2007年工作,我希望還是知道我怎麼能找到會議交換服務器2007上的房間,這將是一個很大的幫助。我想查看Exchange服務器上的所有會議室,然後想要使用它們的屬性。

有沒有一種方法可以顯示所有現有的房間,然後使用其屬性,如電話/備註標籤信息?

我正在使用LDAP,但它一直給我錯誤「服務器不可操作」。我想可能是我使用了錯誤的憑證。所以我嘗試了谷歌,它並沒有幫助我。

隨信附上我的代碼: -

 using (DirectoryEntry dir2 = new DirectoryEntry("LDAP://www.google.com/DC=www,DC=google,DC=com", null, null, AuthenticationTypes.Encryption)) 
     { 
      dir2.RefreshCache(); 

      DirectorySearcher adSearch = new DirectorySearcher(dir2); 
      adSearch.Filter = "(&(objectClass=*)(msExchRecipientDisplayType=7))"; 
      SearchResultCollection adResult = adSearch.FindAll(); 

      foreach (SearchResult item in adResult) 
      { 

       ResultPropertyCollection property = item.Properties; 

       ResultPropertyValueCollection name = property["name"]; 
       ResultPropertyValueCollection proxyAddresses = property["proxyAddresses"]; 
       ResultPropertyValueCollection legacyExchangeDN = property["legacyExchangeDN"]; 

       .......... 
     } 
} 

它給了我錯誤的封閉代碼: - dir2.RefreshCache(); 我不知道,我在做什麼錯。我曾與不同的LDAP值的嘗試,如: - using (DirectoryEntry dir2 = new DirectoryEntry("LDAP://ldap.google.com/DC=www,DC=google,DC=com", null, null, AuthenticationTypes.Encryption))

using (DirectoryEntry dir2 = new DirectoryEntry("LDAP:///DC=www,DC=google,DC=com", null, null, AuthenticationTypes.Encryption))

using (DirectoryEntry dir2 = new DirectoryEntry("LDAP://DC=www,DC=google,DC=com", null, null, AuthenticationTypes.Encryption))

但沒有真正幫助了我。

你知道我在做什麼錯嗎?

隨函附上堆棧跟蹤:

at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) 
    at System.DirectoryServices.DirectoryEntry.Bind() 
    at System.DirectoryServices.DirectoryEntry.RefreshCache() 
    at Test_Exchange.Program.Main(String[] args) in C:\Inetpub\wwwroot\Test Exchange\Test Exchange\Program.cs:line 26 
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Threading.ThreadHelper.ThreadStart() 

任何幫助或建議將不勝感激。

在此先感謝!

+0

如果您的計算機已加入域,則應該只能執行DirectoryEntry dir2 = new DirectoryEntry()。那樣有用嗎? –

回答

0

我想分享我做錯了什麼。它可以幫助其他人。 現在運行良好。這個問題是錯誤的廣告名稱。 請諮詢IT或管理員以確認您是否使用了正確的Active Directory名稱。

乾杯!

+1

僅供參考,在StackOverflow上,您需要通過單擊該答案旁邊的複選標記來標記將您的問題解決爲答案的答案。人們更不願意回答那些不這樣做的人的問題。 –

相關問題