Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:04:07+00:00 2026-05-26T13:04:07+00:00

I am trying to run following program: package jndi; import java.util.Hashtable; import javax.naming.Context; import

  • 0

I am trying to run following program:

package jndi;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;


public class LDAPRead {

    public static void main(String[] args) {

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=jaydeetechnology");
        try{
            System.out.println("creating initial directory context");
            DirContext ctx = (DirContext) new InitialContext(env);
            System.out.println("search for john hunt");
            Attributes attrs = ctx.getAttributes("cn=John Hunt , ou=JayDeeTechnology");
            System.out.println("find the surname and print it");
            System.out.println("sn: "+attrs.get("sn").get());
            ctx.close();
        }catch(NamingException e){
            e.printStackTrace();
        }
    }

}

but I am getting ‘Connection refused’ error. Could any one please help me if I am missing something?

creating initial directory context
javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:222)
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:130)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1592)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2664)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:305)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:187)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:205)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:148)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:78)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
    at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:318)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:348)
    at javax.naming.InitialContext.internalInit(InitialContext.java:286)
    at javax.naming.InitialContext.<init>(InitialContext.java:211)
    at jndi.LDAPRead.main(LDAPRead.java:31)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:383)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:245)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:232)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:377)
    at java.net.Socket.connect(Socket.java:539)
    at java.net.Socket.connect(Socket.java:488)
    at java.net.Socket.<init>(Socket.java:385)
    at java.net.Socket.<init>(Socket.java:199)
    at com.sun.jndi.ldap.Connection.createSocket(Connection.java:364)
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:199)
    ... 14 more

I am using RSA 8.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:04:08+00:00Added an answer on May 26, 2026 at 1:04 pm

    From the Adobe LDAP Troubleshooting pages:

    Error: javax.naming.CommunicationException: [server]:[port] [Root exception is java.net.ConnectException: Connection refused: connect]
    
    Cause: The port name you have specified for the LDAP/AD server is incorrect.
    

    I’d say your using the wrong hostname, the wrong port number, or haven’t started you LDAP installation on that server yet.

    Try looking in the LDAP server’s logs, perhaps you can learn a bit more from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to run the following python program import re regex=re.compile(http...imgs.xkcd.com.comics.[\\S]*.[jpg|png]) f=open('out.txt') for a
Trying to run my program through java web start. I get the following exception
Hey everyone, I am trying to run the following program, but am getting a
Trying to run my program in FreeBSD OS, I have the following results: $
When i am trying to run my program it is giving the following error
I am trying to run a java program in linux environment. The program is
When trying to run the following program code, this error occurred; Input string was
I am trying to run the following HelloWorld Script at Command Line import tornado.httpserver
I've been trying for an hour to run the following program with a the
I am trying to run the following code in vbscript: ReturnCode = WshShell.Run(C:\Program Files\Virtutech\Simics

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.