1

I am trying to add a referral object in openldap that points to a DN in the remote server that has a space in one of the container names, something like this

ref: ldap://ldap3.example.com/ou=test ou,dc=example,dc=net

This seems to be causing a problem, what is the syntax for "escaping" spaces within ldif files, backslash before the space? whole attribute value within quotes?

Thanks for the help

Haddad
  • 141
  • 1
  • 4

2 Answers2

2

I know this is an old thread but maybe this'll help someone... replacing space characters with %20 worked for me.

5string
  • 21
  • 2
  • And this is the correct way! Attribute *ref* contains an LDAP URL and thus [RFC 4516](https://tools.ietf.org/html/rfc4516) is relevant here. Nevertheless the DN has to be a correct string representation (see [RFC 4514](https://tools.ietf.org/html/rfc4514)) **before** you apply the URL-quoting. In this particular case the space in the DN is correct DN string representation and thus the URL quoting is just right. – Michael Ströder Feb 05 '19 at 18:19
0

Per RFC 4514, you should also be able to escape the space in the following ways:

Backslash the character needing to be escaped.

ref: ldap://ldap3.example.com/ou=test\ ou,dc=example,dc=net

Double-quote the entire value with the character needing to be escaped. This will not help if the character that needs an escape is a double-quote. This is especially helpful if you have multiple characters in the value that require escaping.

ref: ldap://ldap3.example.com/ou="test ou",dc=example,dc=net

The RFC 4514 2.4 method of escaping special characters is a backslash followed by a two digit hex code for each byte.

ref: ldap://ldap3.example.com/ou=test\20ou,dc=example,dc=net
Ed Grimm
  • 298
  • 3
  • 8