[débutante] JNDI ldap
auderyu
-
bigoliver -
bigoliver -
Bonjour,
Je commence à peine à apprendre le JNDI et j'ai fais ce code pour me connecter:
public static void main(String[] args) throws NamingException {
try {
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://localhost:389");
env.put(Context.SECURITY_AUTHENTICATION,"sasl");
env.put(Context.SECURITY_PRINCIPAL, "cn=ldap-admin,dc=test-ldap,dc=net");
env.put(Context.SECURITY_CREDENTIALS, "ldap-admin");
Context ictx = new InitialContext(env);
NamingEnumeration<NameClassPair> e = ictx.list("cn=userA");
while (e.hasMore()) {
System.out.println("name : " + e.next().getName());
}
} catch (javax.naming.NamingException e){
System.err.println("Exception : " + e);
};
Et sa m'affiche l'erreur:
Exception : javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]
Pouvez-vous m'aider?
Je commence à peine à apprendre le JNDI et j'ai fais ce code pour me connecter:
public static void main(String[] args) throws NamingException {
try {
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://localhost:389");
env.put(Context.SECURITY_AUTHENTICATION,"sasl");
env.put(Context.SECURITY_PRINCIPAL, "cn=ldap-admin,dc=test-ldap,dc=net");
env.put(Context.SECURITY_CREDENTIALS, "ldap-admin");
Context ictx = new InitialContext(env);
NamingEnumeration<NameClassPair> e = ictx.list("cn=userA");
while (e.hasMore()) {
System.out.println("name : " + e.next().getName());
}
} catch (javax.naming.NamingException e){
System.err.println("Exception : " + e);
};
Et sa m'affiche l'erreur:
Exception : javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]
Pouvez-vous m'aider?
Configuration: Windows XP Internet Explorer 6.0
A voir également:
- [débutante] JNDI ldap
- Ldap client windows - Télécharger - Édition & Programmation
- Ldap tool box - Télécharger - Récupération de données
- Samba ldap - <a href="https://forums.commentcamarche.net/forum/linux-unix-13">Forum Linux / Unix</a>
- Ldap glpi - <a href="https://forums.commentcamarche.net/forum/gestion-de-parc-241">Forum Gestion de parc</a>
- Idm ldap - Télécharger - Téléchargement & Transfert
1 réponse
Salut,
Surement tu as déjà résolu ce problème vu la date. Mais pour ceux qui passeront par là, voici les causes possibles:
1 - Ton serveur LDAP ne tourne pas.
2 - Ton serveur LDAP n'écoute pas sur le port 389
3 - Impossible de se connecter à l'ordinateur sur lequel est installé le serveur LDAP(dans le cas où ce n'est pas la machine locale)
Hope that it will be useful for someone.
Surement tu as déjà résolu ce problème vu la date. Mais pour ceux qui passeront par là, voici les causes possibles:
1 - Ton serveur LDAP ne tourne pas.
2 - Ton serveur LDAP n'écoute pas sur le port 389
3 - Impossible de se connecter à l'ordinateur sur lequel est installé le serveur LDAP(dans le cas où ce n'est pas la machine locale)
Hope that it will be useful for someone.