访问win2000 Active Directory信息的代码
发表于:2007-06-30来源:作者:点击数:
标签:
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
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("LDAP://microsoft");
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("===========================================");
}
}
}
}
原文转自:http://www.ltesting.net