i am building a csharp application and i would like a dropdown list of all users in my outlook global address book (the same one when i click on To: from outlook gui. is this possible to get this progrmaticall? what are the security requirements here?
问问题
7012 次
1 回答
2
过去,除了 Outlook 依赖性之外,安全后果使我无法使用这种方法。结果,我最终以LDAP 查询的形式构建了它。另一个优点是,(在回答您的其他问题时)您将能够提取联系信息,因为此信息存储在 Active Directory 中。
免责声明:我看这段代码已经快五年了,所以我恐怕不再完全理解这个查询。但是,希望这足以让您入门。
DirectoryEntry adFolderObject = new DirectoryEntry();
DirectorySearcher adSearcher = new DirectorySearcher(adFolderObject);
adSearcher.SearchScope = SearchScope.Subtree;
adSearcher.Filter = "(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ))";
foreach (SearchResult adObject in adSearcher.FindAll())
{
Console.WriteLine("CN={0}, Path={1}", adObject.Properties["CN"][0], adObject.Path);
}
于 2009-11-28T05:22:15.363 回答