title: How to perform search operation in ldap using spring
body: <p>I want to search specific user details from ldap. so i have wrote down following code retrieving user details but it returns list of user object. Basically i want only person obejct not list of person objects. for retreiving  i m using ldap template. How can i modify this code so that it return person object?</p>
  
  <pre><code>public void searchByFirstName(String loginId) {
  
          AndFilter filter = new AndFilter();
          filter.and(new EqualsFilter("objectclass", "Person"));
          filter.and(new EqualsFilter("cn", loginId));
          List list = ldapTemplate.search("", 
              filter.encode(),
              new AttributesMapper() {
                  public Object mapFromAttributes(Attributes attrs) throws NamingException        {
                      return attrs.get("sn").get();
                  }
              });
  
  
  }
  </code></pre>