title: ldap_search will not accept filter with parentheses in the search input
body: <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>