如何获取位于LDAP组织单位内的每个用户和/或组的列表?
我正在尝试使用c#
查询我的LDAP
服务器。我想要获取我所有通讯组列表的列表。我的所有通讯组列表都分组在一个称为"General Distributions“的组织单元(OU)下。如何获取"General Distribution“OU下的所有成员的列表?
下面是我用来查询没有返回任何结果的LDAP
服务的代码。
try
{
DirectoryEntry objADAM = new DirectoryEntry("LDAP://my_domain.com", "user@my_domain.com", "password");
DirectorySearcher objSearchADAM = new DirectorySearcher(objADAM);
objSearchADAM.Filter = "(&(OU=General Distributions,DC=my_domain,DC=com)";
objSearchADAM.SearchScope = SearchScope.Subtree;
SearchResultCollection objSearchResults = objSearchADAM.FindAll();
// Binding path.
List<string> result = new List<string>();
if (objSearchResults.Count != 0)
{
foreach (SearchResult objResult in objSearchResults)
{
DirectoryEntry objGroupEntry = objResult.GetDirectoryEntry();
result.Add(objGroupEntry.Name);
}
return result;
}
throw new Exception("No result found");
}
catch (Exception e)
{
throw e;
}
https://stackoverflow.com/questions/51254981
复制