1
string path = "LDAP://192.168.0.20/CN=users,DC=company,DC=ltm,DC=dom";

DirectoryEntry dir = new DirectoryEntry(path, admin, pass, AuthenticationTypes.ServerBind);

object value = dir.Properties["description"].Value;
dir.Properties["description"].Value = "test";
dir.CommitChanges();

该代码在 dir.Properties["description"].Value 处生成 COMException : "Invalid DN syntax"

如果我没有指定任何用户名和密码,并将 DirectoryEntry 初始化替换为:

DirectoryEntry dir = new DirectoryEntry(path);
dir.AuthenticationType = AuthenticationTypes.ServerBind;

然后我在 CommitChanges 得到 UnauthorizedAccessException。

非常感谢任何关于可能出错的想法。

4

2 回答 2

1

你试过没有指定AuthenticationTypes吗?

就像:

DirectoryEntry dir = new DirectoryEntry(path, admin, pass);
于 2010-01-22T10:01:04.060 回答
0

好吧,如果您尝试在没有密码和用户名的情况下登录,您将获得 UnauthorizedAccess。

这实际上取决于 LDAP 服务器的配置方式,但这似乎不允许匿名访问。

我认为应该在没有 LDAP://CN=users,DC=company,DC=ltm,DC=dom 之类的 IP 地址的情况下定义路径,但我没有在 .NET 中使用,所以我不能肯定地说。

于 2010-01-22T09:50:17.913 回答