读书人

活动目录编程出现异常

发布时间: 2012-01-05 22:36:54 作者: rapoo

活动目录编程出现错误
我现在在写域的管理类,有一个问题,

LDAP://172.16.0.2/CN=Users;DC=huiren,DC=cn

这是我的域的联接字符串

域服务品的IP是172.16.0.2

域名是huiren.cn

可是我就是联接不上去

System.DirectoryServices.DirectoryEntry myds=new System.DirectoryServices.DirectoryEntry("LDAP://172.16.0.2/CN=Users;DC=huiren,DC=cn","adminstrator","******");

总是在这一步报错,

我想请你看一下,是什么地方报错



代码如下:

try
{
System.DirectoryServices.DirectoryEntry root =new System.DirectoryServices.DirectoryEntry("LDAP://172.16.0.2/CN=Users;DC=huiren,DC=cn","adminstrator","******");
foreach(DirectoryEntry domain in root.Children)
{
Response.Write("Domain | WorkGroup:\t"+domain.Name +"<br>");
foreach(DirectoryEntry computer in domain.Children)
{
Response.Write("Computer:\t"+computer.Name +" Path:\t"+computer.Path+" PropertyNames:\t"+computer.Properties.PropertyNames+"<br>");
}
}
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}

报错:出现了一个操作错误。



[解决办法]
What's the detail of this exception?
[解决办法]
LDAP://172.16.0.2/CN=Users;DC=huiren,DC=cn,那个分号改成逗号试一下。
[解决办法]
LDAP://OU=BAMTRIEMPLOYEE,DC=bamtri,DC=avic1

读书人网 >C#

热点推荐