» 网友学堂 » Director教程 » 访问win2000 Active directory信息的代码
访问win2000 Active directory信息的代码
作者:lonjew 发表时间:2008-4-15 08:53 阅读:97次 在百度搜索相关内容

using System;
using System.DirectoryServices;
namespace ActiveDirectory
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main (string args)
{
//Note : microsoft is the name of my domain for testing purposes.
DirectoryEntry entry = new DirectoryEntry("
[url=ldap://microsoft]LDAP://microsoft[/url]
");
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=*)");
Console.WriteLine("Active Directory Information");
Console.WriteLine("===========================================");

foreach(System.DirectoryServices.SearchResult resEnt
in mySearcher.FindAll())
{
Console.WriteLine( resEnt.GetDirectoryEntry().Name.ToString() );
Console.WriteLine( resEnt.GetDirectoryEntry().Path.ToString() );
Console.WriteLine( resEnt.GetDirectoryEntry().NativeGuid.ToString() );
Console.WriteLine("===========================================");
}
}
}
}

#Advertisement