2014-09-01 5 views
0

exchange/active 디렉토리의 모든 전자 메일 목록을 가져와야합니다.
[email protected]과 같은 전자 메일 또는 전자 메일 그룹을 포함하는 모든 연락처 또는 CEO와 같은 전자 메일 그룹.
C# MS Exchange의 모든 전자 메일 주소를 나열하십시오.

DirectoryEntry de = new DirectoryEntry(ad_path); 
DirectorySearcher ds = new DirectorySearcher(de); 
ds.Filter = "(&(objectClass=addressBookContainer)(CN=All Global Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomain,DC=local))"; 
SearchResultCollection ss = ds.FindAll(); // count = 0 

답변

1

당신은이 디렉토리 밖으로 Mailadresses을받지 않습니다이 단지 구성 개체, 개체를 직접 :
이 지금까지 내 코드입니다. ,

 DirectoryEntry de = new DirectoryEntry(); 
     DirectorySearcher ds = new DirectorySearcher(de); 
     ds.PropertiesToLoad.Add("proxyAddresses"); 
     ds.Filter = "(&(proxyAddresses=smtp:*))"; 
     SearchResultCollection ss = ds.FindAll(); // count = 0 

     foreach (SearchResult sr in ss) 
     {// you might still need to filter out other addresstypes, ex: sip: 
      foreach (String addr in sr.Properties["proxyAddresses"]) 
       Console.WriteLine(addr); 
//or whithout the 'smtp:' prefix Console.WriteLine(addr.SubString(5)); 

     } 

특정 Exchange 주소 목록의 내용을 얻을하려는 경우 : 당신은 단순히 모든 Mailadresses 당신의 조직에서 당신은 단순히 다음과 같은 쿼리 수를 원한다면 (기본적으로 제한 ResultSize 선택이 있습니다) 당신은 당신의 필터를 수정하고, 예를 들어,이 목록의 'purportedSearch'-재산권의 가치로 교체 할 수 있습니다 : "기본 전체 주소 목록"에 대한 기본 필터는

(&(mailNickname=*)(|(objectClass=user)(objectClass=contact)(objectClass=msExchSystemMailbox)(objectClass=msExchDynamicDistributionList)(objectClass=group)(objectClass=publicFolder))) 

합니다. 또는 (CN = 모든 전체 주소 목록, CN = 주소 목록 컨테이너, CN = 첫 번째 조직, CN = Microsoft Exchange, CN = 서비스, CN = 구성, DC = mydomain, DC = 로컬)에있는 모든 AddressBookContainer 개체를 enum 할 수 있습니다. ~ 각 'purportedSearch'- 속성을 사용하여 쿼리를 수행하십시오.