【问题标题】:LDAP Invalid DN SyntaxLDAP 无效的 DN 语法
【发布时间】:2010-01-22 09:19:48
【问题描述】:
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。

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

【问题讨论】:

    标签: ldap directoryentry


    【解决方案1】:

    你试过不指定AuthenticationTypes吗?

    就像:

    DirectoryEntry dir = new DirectoryEntry(path, admin, pass);
    

    【讨论】:

    • 是的,但是我得到了一个 DirectoryServicesCOMException,它告诉我连接到这台机器的单元不起作用。
    • @remdao,您的计算机是否加入了该域?
    • 没有我正在连接的计算机有它自己的域。我认为这是问题所在,感谢您的帮助:)
    【解决方案2】:

    如果你尝试在没有密码和用户名的情况下登录,你会得到 UnauthorizedAccess。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多