C# 目录项属性
我对我的C#项目有一个简短的要求。我想读出我们的active directory并使用以下内容:C# 目录项属性,c#,active-directory,C#,Active Directory,我对我的C#项目有一个简短的要求。我想读出我们的active directory并使用以下内容: System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry); foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll()) {
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)
{ }
}
现在我想读出其他属性,希望你能给我一个所有属性的列表
谢谢您只需使用下面的代码即可完成
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)
{ }
}
你能再解释一下吗?谢谢:)这正是我需要的