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 8854283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:50:48+00:00 2026-06-14T13:50:48+00:00

If one uses ldapsearch to search a particular LDAP server for base level naming

  • 0

If one uses ldapsearch to search a particular LDAP server for base level naming contexts, the search works fine.

$ ldapsearch -h myhealthisp.com -p 10389 -x -s base -b "" namingContexts
# extended LDIF
#
# LDAPv3
# base <> (default) with scope baseObject
# filter: (objectclass=*)
# requesting: namingContexts
#

#
dn:
namingContexts: dc=myhealthisp,dc=com

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1`

Using the JNDI, however, we get the following response:

No Results for: myhealthisp.com.
Problem: [LDAP: error code 32 - No Such Object] null

Here’s our code:

private Attribute getCertFromLdap(SRVRecord srvRec, CertificateInfo certInfo) throws CertLookUpException{
    env.put(DirContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    sc1 = new SearchControls();
    sc1.setSearchScope(SearchControls.ONELEVEL_SCOPE);

try {
        env.put(DirContext.PROVIDER_URL, "ldap://" + targetDomain + ":" + srvRec.getPort());        
        System.out.println("ldap://" + targetDomain + ":" + srvRec.getPort());

        DirContext dc = new InitialDirContext(env);
        NamingEnumeration directoryNE = null;

        System.out.println("Got HERE!");
        directoryNE= dc.search("", "objectClass=*", sc1);

        System.out.println("SC1 :" + sc1);
        while (directoryNE.hasMore()){
                        SearchResult result1 = (SearchResult) directoryNE.next();

            // print DN of entry
            System.out.println("Result.getNameInNamespace: " + result1.getName());
            Attribute foundMail = findMailAttribute(result1.getNameInNamespace()); 

            if(foundMail != null){
                return foundMail;
            }
        }       
        dc.close(); 
} catch (NamingException e) {
    System.out.println("No Results for: " + targetDomain + "\nProblem: " +     e.getLocalizedMessage() + "  " + e.getCause());
} return null;

}

The only way that we are able to return the base directories for myhealthisp.com is by hard coding the directory name (dc=myhealthisp,dc=com) into the base directory search filter (see this for what we are basing our code off of: http://directory.apache.org/apacheds/manuals/basic-user-guide-1.5.8-SNAPSHOT/html/ch03s03.html#LDAP Operations Searching)

When our code searches onctest.org LDAP server, we are given each of the namingContexts back.

Here’s the output to the Eclipse console for both the onctest.org server and the myhealthisp.com server:

ldap://onctest.org.:10389
Got HERE!
SC1 :javax.naming.directory.SearchControls@4c408bfc
Result.getNameInNamespace: ou=config
Result.getNameInNamespace: dc=example,dc=com
Result.getNameInNamespace: ou=system
Search Result: cn=dts556: null:null:{mail=mail: dts556@onctest.org,     usercertificate=userCertificate: [B@35e06ba6, objectclass=objectClass: organizationalPerson,     person, inetOrgPerson, top, o=o: onctest, sn=sn: Test Case, cn=cn: dts556}

Service Record: _ldap._tcp.onctEst.org. 86400   IN  SRV 0 0 10389 onctest.org.
ldap://myhealthisp.com.:10389
Got HERE!
No Results for: myhealthisp.com.
Problem: [LDAP: error code 32 - No Such Object]  null
Unable to find certificate at LDAP for: steve.tripp@myhealthisp.com
_ldap._tcp.myhealthisp.com. 3600    IN  SRV 0 0 10389 myhealthisp.com.

We think that the following is causing the problem:

  • JDNI cannot do a base search for OpenLDAProotDSE objectClass directories.
  • 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-06-14T13:50:49+00:00Added an answer on June 14, 2026 at 1:50 pm

    Generally anonymous bind doesnt have privilege to do a ldap search on the root. Every directory has the OOTB privileges for anonymous bind and searching the root. In case of apache DS, a search of the naming contexts can be done via the ldap query

    ldapsearch -h localhost -p 10389 -s base -b “” “(objectclass=*)” namingContexts

    However, a one level search of subtree search such as

    ldapsearch -h localhost-p 10389 -s one -b “” -D “uid=admin,ou=system” -w secret “(objectclass=*)”

    Gives the following result: which is what you are doing in the jndi program:
    ldap_search: No such object
    ldap_search: additional info: NO_SUCH_OBJECT: failed for SearchRequest
    baseDn : ”
    filter : ‘(2.5.4.0=*)’
    scope : single level
    typesOnly : false
    Size Limit : no limit
    Time Limit : no limit
    Deref Aliases : never Deref Aliases
    attributes :
    : null

    JNDI code for the first ldapsearch command :

    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.directory.Attribute;
    import javax.naming.directory.Attributes;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    import javax.naming.directory.SearchControls;
    import javax.naming.directory.SearchResult;
    
    public class SampleLDAPSearch {
    
      private Attribute getCertFromLdap() {
          String targetDomain = "localhost";
          String port = "10389";
    
          Hashtable env = new Hashtable();
          env.put(DirContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
          SearchControls sc1 = new SearchControls();
          sc1.setSearchScope(SearchControls.OBJECT_SCOPE);
          sc1.setReturningAttributes(new String[] { "namingContexts" });
    
          try {
              env.put(DirContext.PROVIDER_URL, "ldap://" + targetDomain + ":" + port);
    
              System.out.println("ldap://" + targetDomain + ":" + port);
    
              DirContext dc = new InitialDirContext(env);
              NamingEnumeration directoryNE = null;
    
              System.out.println("Got HERE!");
              directoryNE = dc.search("", "objectclass=*", sc1);
    
              System.out.println("SC1 :" + sc1);
              while (directoryNE.hasMore()) {
                  SearchResult result1 = (SearchResult) directoryNE.next();
    
                  // print DN of entry
                  System.out.println("Result.getNameInNamespace: " + result1.getName());
                  Attributes attrs = result1.getAttributes();
                  Attribute attr = attrs.get("namingContexts");
                  System.out.println(attr);
    
              }
              dc.close();
          } catch (NamingException e) {
              System.out.println("No Results for: " + targetDomain + "\nProblem: " + e.getLocalizedMessage() + "  "
                      + e.getCause());
          }
          return null;
    
      }
    
      public static void main(String[] args) {
          SampleLDAPSearch sls = new SampleLDAPSearch();
          sls.getCertFromLdap();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am looking for a js/jQuery plugins datepicker like this http://www.styledisplay.com/mootoolsdatepicker/ because this one uses
Here's what I'm envisioning. Take a database (this one uses sql server 2008 spatial
I have a production server running, and a local development one (this one uses
Which one is faster? Which one uses less memory? Console.WriteLine(string1) Console.WriteLine(string2) Console.WriteLine(string3) Console.WriteLine(stringNth) or
I have 2 canvases, one uses HTML attributes width and height to size it,
How to use such functionality of windows-7 with WPF (one that uses Itunes -
I am currently building an making my new website. It uses one page and
I have the following two queries, I believe that the one that uses the
I'm writing a simple socket client which uses only one socket. So I figured
I'm trying to set up a slider that uses just one control-menu (e.g. Item

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.