I'm trying to add an Active Directory record via PHP. The CN contains a apostrophe (single quote), and I'm trying to find the correct way to escape it.
Things I've tried:
$dn = "CN=Conan O'Brien,OU=test,DC=test";
ldap_add($link_id, $dn, $attributes);
ldap_add($link_id, addslashes($dn), $attributes);
ldap_add($link_id, str_replace("'", "\\39", $dn), $attributes);
Each one gives the same error. Obviously, I have verified this code works without an apostrophe in the DN.
ldap_add(): Add: Invalid syntax