1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| NamingEnumeration<?> results = ctx.search("dc=example,dc=com","(objectclass=posixGroup)",constraints);
System.out.println("Groupes de l'annuaire");
//Pour chaque entrée, afficher les attributs
while (results != null && results.hasMore()){
//Lire une entrée
SearchResult entry = (SearchResult)results.next();
//Imprimer le DN
System.out.println("DN: "+ entry.getName());
Attributes attrs = entry.getAttributes();
if (attrs == null){
System.out.println("Pas d'attributs");
}
else{
//Afficher chaque attribut
for (NamingEnumeration<?> attEnum = attrs.getAll(); attEnum.hasMoreElements();){
Attribute attr = (Attribute)attEnum.next();
String attrId = attr.getID();
//Afficher toutes les valeurs d'un attribut
for(Enumeration<?> vals=attr.getAll(); vals.hasMoreElements();
System.out.println(attrId + ": " + vals.nextElement()));
}
}
System.out.println();
} |
Partager