Note that there are some explanatory texts on larger screens.

plurals
  1. POldap_search will not accept filter with parentheses in the search input
    primarykey
    data
    text
    <p>In a php page I'm working on, an LDAP connection is established from which a list of cn entries are pulled and put into a dropdown. The selection from the dropdown is sent via form submission to another php scrips which checks the selected cn against the LDAP to grab more associated information.</p> <p>For most names this is no problem; however, a cn was recently added that includes parentheses enclosing a nickname, and when that name is selected it causes the ldap_search() method to return false. Below is the code, where $employeename is the sanitized employee name.</p> <pre><code>... $dn = "cn=users,dc=our-domain,dc=com"; $filter = "(cn=".$employeename.")"; $attrs = array("cn", "mail"); $rslt = ldap_search($ldapsvr, $dn, $filter, $attrs); $entries = ldap_get_entries($ldapsvr, $rslt); ... </code></pre> <p>The $filter string ends up as </p> <pre><code>(cn=First (FN) Last) </code></pre> <p>where First is the first name, Last is the last name, and FN is the included nickname. I have tried escaping the parentheses as \28 and \29 (as provided <a href="http://www.rlmueller.net/CharactersEscaped.htm" rel="nofollow">here</a>, where it also says matched parentheses do not need to be escaped), but it did not help. Names that work include letters, spaced, and periods (for middle initials).</p> <pre><code>(cn=First \28FN\29 Last) </code></pre> <p>EDIT: ldap_search is returning false, not dying. One of the lines I included while investigating would fail and die if $rslt was false and not an array.</p> <p>EDIT: I escaped the inner parentheses only,. as the outer never gave any trouble</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload