返回Person对象的AttributesMapper
Person对象与Attributes转换类:
private class PersonAttributesMapper implements AttributesMapper<Person> { public Person mapFromAttributes(Attributes attrs) throws NamingException { Person person = new Person(); person.setFullName((String)attrs.get("cn").get()); person.setLastName((String)attrs.get("sn").get()); person.setDescription((String)attrs.get("description").get()); return person; } }使用方式:
ldapTemplate.search(query().where("objectclass").is("person"), new PersonAttributesMapper());版权声明:本文为Sheldon74原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。