user2720970
user2720970

Reputation: 294

Escape Space in PHP LDAP DN

I struggling to search LDAP with the BaseDN. Im fairly certain its because of the SPACE in the OU. It does work with a simple DN (No spaces)

This is my DN:

$ldap_dn = "OU=Distribution Groups,OU=MyCompany,DC= mycompany,DC=localnet";

I have tried "\ ", &20, \20 Nothing works.

I have also tried:

$ldap_dn_bad = "OU=Distribution Groups,OU= MyCompany,DC= mycompany,DC=localnet";
$ldap_dn  = ldap_escape($ldap_dn_bad, null, LDAP_ESCAPE_FILTER);

Upvotes: 1

Views: 1228

Answers (1)

Esteban
Esteban

Reputation: 1815

From my understanding of the LDAP String Representation of Distinguished Names RFC (https://www.rfc-editor.org/rfc/rfc4514)

Spaces are allowed without need to be escaped inside the value of an AttributeValue, but not leading/traling spaces in the value :

  • OU=Distribution Groups : OK -> value is Distribution Groups
  • DC= mycompany : NOT OK -> value is [ ]mycompany. (without brackets)

I would try either :

Upvotes: 1

Related Questions