DirectoryServices似乎爲我做了詭計。創建指向動態通訊組列表一個DirectoryEntry(架構類名=「msExchDynamicDistributionList」),然後使用「msExchDynamicDLBaseDN」和「msExchDynamicDLFilter」屬性搜索成員:
using (var group = new DirectoryEntry("LDAP://CN=MyGroup,OU=MyOU,DC=company,DC=com"))
{
string baseDN = (string)group.Properties["msExchDynamicDLBaseDN"].Value;
string filter = (string)group.Properties["msExchDynamicDLFilter"].Value;
using (var searchRoot = new DirectoryEntry("LDAP://" + baseDN))
using (var searcher = new DirectorySearcher(searchRoot, filter, propertiesToLoad))
using (var results = searcher.FindAll())
{
foreach (SearchResult result in results)
{
// Use the result
}
}
}
記住成員可以是常規組或其他動態通訊組以及用戶,聯繫人和公共文件夾。
這些Exchange 2003或2007/2010 DDG是否? –
Exchange 2010和Exchange Online(Office 365) –