JNDI LDAP problem in JRE 1.4

R

Ray Dees

I have a production app that worked under JRE 1.3.1 but gives an
exception under JRE 1.4.1 and 1.4.2. To illustrate the problem a
small example is shown below. This example is derived from the
SearchWithFilterRetAll example from Sun's JNDI Tutorial. The OS is
Solaris 8 & 9 (SPARC). Would appreciate any suggestions as to the
cause of the problem. Thanks!

import javax.naming.*;
import javax.naming.directory.*;

import java.util.Hashtable;

class filterTest {
public static void main(String[] args) {

Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://server:389/ou=myorgunit,o=organization, c=US");

try {
DirContext ctx = new InitialDirContext(env);
SearchControls ctls = new SearchControls();
String filter = "(&(sn=Smith)(mail=*))";
NamingEnumeration answer = ctx.search("", filter, ctls);
printSearchEnumeration(answer);
ctx.close();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void printSearchEnumeration(NamingEnumeration enum)
{
try {
while (enum.hasMore()) {
SearchResult sr = (SearchResult)enum.next();
System.out.println(">>>" + sr.getName());
System.out.println(sr.getAttributes());
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}


Here is the exception trace (from JRE 1.4.2):

javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such
Object]; remaining name ''
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3013)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at filterTest.main(filterTest.java:18)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top