Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

URGENT: java.net.ConnectException: Connection refused: connect <LDAP>

55 views
Skip to first unread message

bouchi...@free.fr

unread,
May 23, 2003, 4:16:29 AM5/23/03
to
Hello,

I want to connect to a ldap server .. but i have this error:
javax.naming.CommunicationException: loupo:389. Root exception is
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:345)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:157)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:144)
at java.net.Socket.<init>(Socket.java:294)
at java.net.Socket.<init>(Socket.java:121)
at com.sun.jndi.ldap.Connection.<init>(Connection.java:215)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:127)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2398)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:258)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:91)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
at javax.naming.InitialContext.init(InitialContext.java:231)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:142)


With a program in C, there's no problem.

The LDAP server is running on loupo on port 389.
The server is a Linux machine ... the server has been insatlled with
openldap rpm.

This is my program :

Properties env = new Properties();

env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://loupo:389/");

env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "o=admin, c=fr");
env.put(Context.SECURITY_CREDENTIALS, "password");
env.put("java.naming.ldap.version", "2");

DirContext ctx;
try {
ctx = new InitialDirContext(env);

//SearchControls ctrl = new SearchControls();
//ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);

//NamingEnumeration answer = ctx.search("o=Paul, c=FR", "sn=*",ctrl);

} catch (NamingException e) { e.printStackTrace();
}


I try to change the properties (env.put) but no result ...
The LDAP server is only access by the administrator ( the Dn is
"o=admin, c=fr"
and pass is "password"). So I can't connect to the server in anonymous
mode.

Someone have any idea ??

Thanks.

0 new messages