我对我的C#项目有一个简短的要求。我想读出我们的active directory并使用下面的代码:
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
System.DirectoryServices.DirectoryEntry de = resEnt.GetDirectoryEntry();
try
{
myRow["eMail"] = de.Properties["Mail"].Value.ToString();
}
catch (Exception)
{ }
}现在我想读出其他属性,希望您能给我一个所有属性的列表。
谢谢
发布于 2013-07-27 12:50:44
你可以通过下面的代码简单地做到这一点
DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
try
{
foreach (string property in resEnt.Properties.PropertyNames)
{
string value = resEnt.Properties[property][0].ToString();
Console.WriteLine(property + ":" + value);
}
}
catch (Exception)
{ }
}https://stackoverflow.com/questions/17876118
复制相似问题