看看vs.net的文档 System.DirectoryServicesusing System;
using System.Management;
using System.DirectoryServices;
using System.Net;
class Security 
{ static void Main (string[] args)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://domain/DC=domain,DC=com");
foreach(DirectoryEntry objChildDE in entry.Children)
{
if ( objChildDE.SchemaClassName == "User")
{
Console.WriteLine(objChildDE.Path) ;
}
}
}
}
这段程序可以显示 域中的用户!

解决方案 »

  1.   

    System里没有DirectoryServices阿!!
      

  2.   

    我在Reference里找到了
    但是,不知道在web form里能不能用
      

  3.   

    string aa=System.Environment .CurrentDirectory;
      

  4.   

    你在add reference里把System.DirectoryServices.dll加进来不久有了?
      

  5.   

    在Reference里添加后,再到程序开头加上这句话才能用
    using System.DirectoryServices;
      

  6.   

    web form里直接用server.mapath
      

  7.   

    jhnhu
    可不可以解释一下"LDAP://domain/DC=domain,DC=com"
      

  8.   

    LDAP: Lightweight Directory Access Protocol 一种访问目录的协议
    不同系统都有自己的 目录服务(Internet Information Services (IIS),Novell NetWare Directory Service (NDS), NT4是WinNT://)。到了2000的ActiveDirectory就用LDAP,当然2000也兼容WinNT。
    他们都符合ADSI System Providers 这个接口。既然是目录,就有路径。LDAP://domain/DC=domain,DC=com 就是一个域的路径
    new DirectoryEntry("LDAP://domain/DC=domain,DC=com");通过DirectoeyEntry的构造函数得到这个路径的对象,然后进行操作。(domain就是你的域名,com就是一般的.com)LDAP的格式,非常非常复杂,我也不太清楚。一般只对域、工作组、用户操作!
    LDAP://DomainName/CN=UserName,CN=Users,DC=DomainName,DC=com 这是一个用户的路径具体请参考vs.net的document。或到news://msnews.microsoft.com上去问!
    因为使用ldap时,会用到windows验证,可能会出现超时无法操作的错误(可能是我那里服务器的问题)