BOnjour ,
j'ai voulu utilisé le LDAP pour la premiére fois , j'ai utilisé les exemple sur le net comme celui là , mais ça marche pas , je ne sais pas pourquoi
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public static void main(String[] args) { Hashtable<String,String> env = new Hashtable<String,String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap:///o=JNDITutorial"); try { //DirContext ctx = new InitialDirContext(env); Context ctx = new InitialContext(env); // Perform the bind ctx.bind("cn=Favorite Fruit", "Fruit"); // Check that it is bound Object obj = ctx.lookup("cn=Favorite Fruit"); System.out.println(obj.toString()); // Close the context when we're done ctx.close(); } catch (NamingException e) { System.out.println("erreur "+e.getMessage()); } }
Merci
Partager