返回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());