public Map<String, String> getAttributes(User user) throws DataSourceException, ConfigException {
    try {
      String s =
          "(&(objectClass="
              + source.getUsersObjectClassValue()
              + ")("
              + source.getUsersIdKey()
              + "="
              + user.getUid()
              + "))";
      List<SearchResult> r = this.search(s, SecurityEntityType.USER);
      if (!r.isEmpty()) {
        Attributes attrs = r.get(0).getAttributes();
        Map<String, String> items = new HashMap<String, String>();
        NamingEnumeration<? extends Attribute> lst = attrs.getAll();
        while (lst.hasMoreElements()) {
          Attribute attr = lst.nextElement();
          if (attr.get() != null) {
            items.put(attr.getID(), attr.get().toString());
          }
        }

        return items;
      } else {
        return null;
      }
    } catch (javax.naming.AuthenticationException e) {
      throw new ConfigException(e, "LDAP connection failed, please check your settings");
    } catch (NamingException e) {
      throw new DataSourceException(e, "LDAP Exception : " + e.getMessage());
    }
  }
 public Object getAttribute(User user, String attributeName)
     throws DataSourceException, ConfigException {
   try {
     String s =
         "(&(objectClass="
             + source.getUsersObjectClassValue()
             + ")("
             + source.getUsersIdKey()
             + "="
             + user.getUid()
             + "))";
     List<SearchResult> r = this.search(s, SecurityEntityType.USER);
     if (!r.isEmpty()) {
       Attributes attrs = r.get(0).getAttributes();
       return attrs.get(attributeName).get();
     } else {
       return null;
     }
   } catch (javax.naming.AuthenticationException e) {
     throw new ConfigException(e, "LDAP connection failed, please check your settings");
   } catch (NamingException e) {
     throw new DataSourceException(e, "LDAP Exception : " + e.getMessage());
   }
 }