【问题标题】:Escape ldap dn in DirectoryEntry在 DirectoryEntry 中转义 ldap dn
【发布时间】:2014-02-10 03:08:23
【问题描述】:

我正在尝试从 OpenLDAP 服务器获取 DirectoryEntry,以获取看起来像“LDAP://server/cn=John Smith+sn=Smith,ou=people,dc=corp,dc=org”的 dn:

> New-Object "LDAP://server/cn=John Smith+sn=Smith,ou=people,dc=corp,dc=org", "user", "pass", "FastBind"

它返回错误 0x80005000,我认为这意味着 dn 中的某些字符没有被转义。 (对于任何不包含 '+sn=' 的 dn,此代码都可以正常工作)

文档指出,应该转义特殊字符,但以任何方式转义 dn:

  • LDAP://server/cn=John Smith\+sn\=Smith,ou=people,dc=corp,dc=org
  • LDAP://server/cn=John Smith\+sn=Smith,ou=people,dc=corp,dc=org
  • LDAP://server/cn=John Smith\2Bsn\3DSmith,ou=people,dc=corp,dc=org
  • LDAP://server/cn=John Smith,ou=people,dc=corp,dc=org

产生“服务器上没有这样的对象”。

此外,父母您没有在 dn 中列出任何带有 '+sn=' 子字符串的孩子,但 DirectorySearcher 用于特定过滤器,如 '(cn=John Smith)',返回正确的结果。

> $ent = New-Object "LDAP://server/ou=people,dc=corp,dc=org", "user", "pass", "FastBind"
> $ent.Children
.... 
everything, except Jonh Smith
....
> Search-ldap "(cn=John Smith)"
Path                                              Properties
----                                              ----------
LDAP://server/cn=John Smith+sn=Smith,ou=peopl...  {sambapwdlastset, telephonenumber, sn...}

LDAP 浏览器(我假设基于 dotNet LDAP 组件)也不会在父 ou 中显示此条目。

那么,有什么方法可以像这样正确地转义 dn 吗?

更新

Java 客户端工作正常,wireshark 显示 java 发送非转义字符串获取对象,dotNet 发送转义字符串却一无所获。

是否可以转义字符串或重新配置openldap服务器以接受转义字符串?

【问题讨论】:

    标签: .net ldap openldap


    【解决方案1】:

    对于 Windows8(和 Server2012),有一个来自 Microsoft 的修补程序。 http://support.microsoft.com/kb/2802148

    【讨论】:

    • 它不能解决这个问题:它修复了架构缓存错误,当您根本无法对 OpenLDAP 进行查询时。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2021-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多