【发布时间】:2019-04-25 03:49:10
【问题描述】:
我目前管理一个分析电子邮件数据的程序。开发此功能时早期出现的一个问题是,电子邮件的 TO CC 或 BCC 字段中的条目通常不是实际的电子邮件地址,而是某种邮件列表地址。因为应用程序需要准确记录一封电子邮件正在发送给多少人,所以必须扩展分发列表,以便我可以记录电子邮件发送给的最终收件人数量。我能够轻松处理正常的分发列表,但遇到了动态分发列表的障碍。
我已经制定了一个可以做到这一点的工作程序。代码如下:
/// <summary>
/// Get the List of A dynamic distribution Group in Key Value Pairs
/// the key is the CN
/// the value is the filter for the membership of that group
/// </summary>
/// <returns>Dictionary of strings </returns>
public List<DistributionList> GetDynamicDistributionLists(string strEmailAddress)
{
List<DistributionList> distributionLists = new List<DistributionList>();
DomName = "dc=" + Settings.ImpersonatedUserDomain.Replace(".", ",dc=");
using(var group = new DirectoryEntry("GC://" + DomName))
{
using(var searchRoot = new DirectoryEntry("GC://" + Settings.GlobalCatalogServer + "/" + DomName))
using(var searcher = new DirectorySearcher(searchRoot, "(&(ObjectClass=msExchDynamicDistributionList)(proxyAddresses=smtp:" + strEmailAddress.Trim() + "))"))
using(var results = searcher.FindAll())
{
foreach(SearchResult result in results)
{
if(result.Properties.Contains("cn") && result.Properties.Contains("msExchDynamicDLFilter"))
{
DistributionList dl = new DistributionList();
dl.DType = DLT.DDL;
dl.CN = result.Properties["cn"][0].ToString();
dl.FILORDN = result.Properties["msExchDynamicDLFilter"][0].ToString();
distributionLists.Add(dl);
}
}
}
}
return distributionLists;
}
这可行,但如果我想远程运行此代码到站点,我必须在全局目录服务器中打开一个 VPN。有时我会想要远程运行,而我的所有其他代码都可以使用 EWS 远程运行,而无需打开 VPN。所以我试图找到一种使用 ADWS 访问服务器的方法。
谁能帮我找到一些代码,让我可以使用 ADWS 运行上述代码,这样我就不需要打开 VPN。
谢谢,
Siv
【问题讨论】:
标签: active-directory exchange-server exchangewebservices