1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
static public Personne getPersonne(String id) {
try {
LDAPConnection ldap = new LDAPConnection(host, port, username, password);
SearchResult sr = ldap.search(baseDN, SearchScope.SUB, "(uid=" + id + ")");
if(sr.getEntryCount() == 0) {
System.out.println("Aucun résultat pour : " + id);
}
String firstname = sr.getSearchEntries().get(0).getAttribute(firstnameAttribute).getValue();
String lastname = sr.getSearchEntries().get(0).getAttribute(lastnameAttribute).getValue();
Personne p = new Personne();
p.setId(id);
p.setPrenom(firstname);
p.setNom(lastname);
ldap.close();
return p;
}
catch(Exception e) {
e.printStackTrace();
return new Personne();
}
} |
Partager