title: Unable to get the data from LDAP while passing cn as a parameter
body: <p>We are migrating a java based application hosted on RHEL 5 to RHEL 7. It has a feature to search users based on username (cn) from ldap directory installed on the linux server.The above feature is working fine with RHEL 5 having openldap version 2.3.43 in the server.And our application is internally using spring-ldap-core-1.3.1.RELEASE jar to fetch the data from the openldap .JAVA version in old server is 1.7</p>
  
  <p>Currently we are having RHEL 7 ,JBOSS-EAP 7,opendldap 2.4.44 ,java 8 and spring-ldap-core-1.3.1 .</p>
  
  <p>When we are running ldap command directly on server to search the user based on "cn" it is giving us the desired result but via application it is unable to fetch the result using the spring ldap jar </p>
  
  <p>Below is the command use to get result on the server :</p>
  
  <p><code>ldapsearch -x -h localhost -b "cn=xxx,o=xxxUser,dc=eu,dc=xxx,dc=com"</code></p>
  
  <p>With the above command we are getting the desired result but dont know why unable to get using the above jar.</p>
  
  <p>We tried to upgrade spring-ldap-core-1.3.1 to 2.3.2.RELEASE version.But still facing same issue.</p>
  
  <p>We are using below codes to call :</p>
  
  <pre><code>public List&lt;User&gt; searchUsersByUserName(final String userName) {
          AndFilter filter = new AndFilter();
          filter.and(new EqualsFilter("objectClass", "user"));
          filter.and(new WhitespaceWildcardsFilter("cn", userName));      
          return this.processSearchResults(this.ldapTemplate.search("o=xxxUser", filter.encode(), new UserContextMapper()));
      }
  </code></pre>
  
  <p>I am unable to get data from the ldap server for cn and unable to pass it to UserContextMapper .</p>
  
  <p>This is our UserContextMapper class :</p>
  
  <pre><code>/**
   * Context mapper for ldap users.
   */
  public class UserContextMapper implements ParameterizedContextMapper&lt;User&gt; {    
      @Override
      public User mapFromContext(final Object ctx) {
          DirContextAdapter context = (DirContextAdapter) ctx;
          String cn = context.getStringAttribute("cn");
          String surName = context.getStringAttribute("sn");
          String fullName = context.getStringAttribute("displayName");
          String givenName = context.getStringAttribute("givenName");
          String userMail = context.getStringAttribute("usermail");
          User u = new User(cn, surName, fullName, givenName, userMail);
          String[] groupsArray = context.getStringAttributes("memberOf");
          if (groupsArray != null) {
              for (String group : Arrays.asList(groupsArray)) {
                  u.getGroups().add(LdapHelper.getOrganizationalUnit(group));
              }
          }
          return u;
      }
  
  }
  </code></pre>