title: Is my LDAP syntax wrong in search filter
body: <p>This is my first attempt in trying to query our LDAP server for AD info. When I am trying to query the LDAP server here is what I'm trying to retrieve: </p>
  
  <p>I am trying to retrieve all active employees with a countlimit of 500 records whose displayname starts with "sav", has an email address and has a userAccountControl attribute of 512. The problem I'm encountering is that I'm only getting back 8 records total. I should literally be getting back at least 10 records.</p>
  
  <p>I did a separate search on the 2 records that were NOT retrieved in my search and each had an email address and a userAccountControl value of 512.  So I'm not sure why those 2 records were missing. </p>
  
  <p>I'm sure I've done something wrong in my syntax but I cannot find what it is. Any HELP/DIRECTION would be appreciated.  Thank you.</p>
  
  <p>After googling I've defined the SEARCH FILTER as: </p>
  
  <pre><code>String searchFilter = "(&amp;(objectClass=user)(displayname="+displayname+"*"+")(mail=*)(userAccountControl=512))";
  </code></pre>
  
  <p>Please see my complete method below:</p>
  
  <pre><code>public List&amp;lt;String&amp;gt; getAutocompleteEmpRecordsList(String displayname, LdapContext ctx) {
      List&amp;lt;String&amp;gt; activeEmpAttributes = new ArrayList&amp;lt;String&amp;gt;();
      Attributes attrs = null;
      int count = 0;
      int empEmailAddrLen = 0;
      try {
          SearchControls constraints = new SearchControls();
          constraints.setCountLimit(500);          
          constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
          String[] attrIDs = {"displayname", "mail", "userAccountControl"};
          constraints.setReturningAttributes(attrIDs);
          String searchFilter = "(&amp;(objectClass=user)(displayname="+displayname+"*"+")(mail=*)(userAccountControl=512))";
          NamingEnumeration answer = ctx.search("OU=Standard,OU=Users,DC=xxx,DC=org", searchFilter, constraints);
          if (answer != null) {
              while (answer.hasMore()) {
                  attrs = ((SearchResult) answer.next()).getAttributes();
                  if (attrs.get("displayname") != null) {
                      int empNameLen = attrs.get("displayname").toString().length();
                      activeEmpAttributes.add(attrs.get("displayname").toString().substring(13, empNameLen));
                  }
                  count++;
                  ctx.close();
              }
          }
          else {
              throw new Exception("Invalid User");
          }
          System.out.println("activeEmpAttributes: " + activeEmpAttributes);
          System.out.println("count: " + activeEmpAttributes.size());
      } catch (Exception ex) {
          ex.printStackTrace();
      }
      return activeEmpAttributes;
  }
  </code></pre>