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

  • SEARCH
  • Home
  • 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 719541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:39:15+00:00 2026-05-14T05:39:15+00:00

I would like to list or search the root context(s) in a LDAP tree.

  • 0

I would like to list or search the root context(s) in a LDAP tree. I use Apache Directory Server and Java:

    Hashtable<String, String> contextParams = new Hashtable<String, String>();
    contextParams.put("java.naming.provider.url", "ldap://localhost:10389");
    contextParams.put("java.naming.security.principal", "uid=admin,ou=system");
    contextParams.put("java.naming.security.credentials", "secret");
    contextParams.put("java.naming.security.authentication", "simple");
    contextParams.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");

    DirContext dirContext = new InitialDirContext(contextParams);

    NamingEnumeration<NameClassPair> resultList;

    //Works
    resultList = dirContext.list("ou=system");
    while (resultList.hasMore()) {
        NameClassPair result = resultList.next();
        System.out.println(result.getName());
    }

    //Does not work
    resultList = dirContext.list("");
    while (resultList.hasMore()) {
        NameClassPair result = resultList.next();
        System.out.println(result.getName());
    }

I can list the sub nodes of ou=system. But I cannot list the sub nodes of the actual root node. I would like to have this list just like Apache Directory Studio can:
alt text http://lesc.se/stackoverflow/ldap_root_contexts.png

  • 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-14T05:39:15+00:00Added an answer on May 14, 2026 at 5:39 am

    The base DNs can be obtained from the namingContexts attribute of the root node (RootDSE). The code should look like this:

    Attributes attributes = dirContext.getAttributes( "", new String[]{"namingContexts"} );
    Attribute attribute = attributes.get( "namingContexts" );
    NamingEnumeration<?> all = attribute.getAll();
    while(all.hasMore())
    {
        String next = (String)all.next();
        System.out.println(next);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sum( int(i.replace(',',''))if re.search('\d',i)!=None for i in list) I would like to sum all elements
How do I search for anything between these tags, I would like to list
I've opened a shread library with lt_dlopen and would like to search the list
I would like to write a generic function that would search a List(Of T)
I wish to use Google custom search and in particular would like to have
I have two tables, name and address. I would like to list the last_name
I would like to know list of gems which is helpful for creating a
I would like to display a list of records from my database, then for
I would like to create a list of records. I can add one record
I would like to render a list of HTML links in ASP.NET MVC. Note

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.