Bonjour,
je désire recupérer le DN d'une personne présente dans mon annuaire LDAP.
Cependant, j'arrive à récupérer tous les attributs liés à cette personne sauf le dn alors qu'avec un client LDAP de type MaxWare, je retrouve bien le DN...
Pourquoi ?
Voici le code
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 try { Hashtable hashtableEnvironment = new Hashtable(); hashtableEnvironment.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" ); hashtableEnvironment.put( Context.PROVIDER_URL, "ldap://host:389/" ); DirContext context = new InitialDirContext(hashtableEnvironment); SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); NamingEnumeration resultat = context.search ("o=xxxx,C=FR","uid=toto",searchControls); System.err.println(resultat); while(resultat.hasMore()) { SearchResult sr = (SearchResult) resultat.next(); Attributes attributs = sr.getAttributes(); NamingEnumeration e = attributs.getAll(); while(e.hasMore()){ System.err.println(e.next()); } }