如何检查Active Directory中是否存在地址列表?

时间:2014-04-24 09:09:38

标签: c# active-directory

在获取所有项目之前,我需要检查Active Directory中是否存在所有全局地址列表,所有地址列表和所有系统地址列表。

你能给我一些我可以解决问题的建议或文章吗?

感谢。

1 个答案:

答案 0 :(得分:1)

地址列表是Exchange功能的一部分,而不是Active Directory,我认为人们对此感到困惑。

无论如何,地址列表数据存储在Active Directory配置上下文中:

CN=Address Lists Container,CN=<EXCHANGE ORGANIZATION NAME>,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=<DEFAULT NAMING CONTEXT>

您可以使用ADSIEdit查看信息。

在C#中,您可以使用LDAP查询来检索现有地址列表的信息。

编辑:这样的事情:

DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
DirectoryEntry configContainer = new DirectoryEntry("LDAP://" + rootDSE.Properties["configurationNamingContext"].Value);
DirectorySearcher configSearcher = new DirectorySearcher(configContainer);
configSearcher.Filter = "(&(objectClass=addressBookContainer))";
configSearcher.PropertiesToLoad.Add("displayName");
configSearcher.PageSize = 10000;
configSearcher.SearchScope = SearchScope.Subtree;
SearchResultCollection results = configSearcher.FindAll();