Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LDAP error

tien liu
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone give me some pointers on the problem below?
1. I've set up a web service that authenticates the user id and password. I'm using Sun's ldap jars (jndi.jar, ldapsec.jar, ldapbp.jar, ldap.jar).
2. Everything works fine, but twice the user couldn't log on to the application and the following error message was found in the log:
>>(Tue Jun 17 10:56:56 EDT 2003) Processing SOAP request...
olRunnable@149B9A0/161D958: <unowned>
Waiting to be notified:
"Thread-18" (0x5bb55e8)
Registered Monitor Dump:
SymcJIT Method Monitor: <unowned>
SymcJIT Method Monitor: <unowned>
SymcJIT Lazy Queue Lock: <unowned>
Waiting to be notified:
"SymcJIT-LazyCompilation-0" (0x4a1b760)
"SymcJIT-LazyCompilation-1" (0x4a177d8)
SymcJIT Method Monitor: <unowned>
SymcJIT Method List Monitor: <unowned>
SymcJIT Lock: <unowned>
utf8 hash table: <unowned>
JNI pinning lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class linking lock: <unowned>
System class loader lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Monitor cache lock: owner "Signal dispatcher" (0x4959c00) 1 entry
Thread queue lock: owner "Signal dispatcher" (0x4959c00) 1 entry
Waiting to be notified:
"Thread-24" (0x2f41e8)
Monitor registry: owner "Signal dispatcher" (0x4959c00) 1 entry
A nonfatal internal JIT (3.10.107(x)) error 'chgTarg: Conditional' has
occurred in :
'com/sun/jndi/ldap/Connection.unpauseReader ()V': Interpreting method.
Please report this error in detail to
A nonfatal internal JIT (3.10.107(x)) error 'chgTarg: Conditional' has
occurred in :
(Lcom/sun/jndi/ldap/LdapRequest Lcom/sun/jndi/ldap/BerDecoder;':
Interpreting method.
Please report this error in detail to

3. Here's the code:
import javax.naming.*;
import java.util.Enumeration;
import java.util.Hashtable;
* This class implements the AuthenticateIF interface and authenticates the user id and password against LDAP.
* It returns an authentication success or failure message to AuthenticateClient.
* @version 1.0
* 11/14/02 web service
public class AuthenticateImpl implements AuthenticateIF
public String errorMessage = "1, Authtentication failed";
public String successMessage = "0, Authentication successful";
public String processAuthenticate(String ldapURL, String uid, String ouString, String oString, String pwd, String ldapBase, String ldapFilter)
DirContext ctx = null;
// create an environment for the initial directory context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
System.out.println("start Security");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "uid=" + uid + ", " + ouString + ", " + oString); // "uid=" + uid + ", ou=xxx, o=xxxx"
env.put(Context.SECURITY_CREDENTIALS, pwd);
System.out.println("end Security");
// create the initial directory context
ctx = new InitialDirContext(env);
String base = ldapBase; //"cn=xxx,ou=xxxx,o=xxxxx"
String filter = ldapFilter; // "objectclass=groupOfUniqueNames"
// set up and perform the search
SearchControls constraints = new SearchControls();
String attrList[] = { "cn,uniquemember" };
NamingEnumeration results =, filter,constraints);
// ctx.close();
// print the search results
if (!results.hasMore())
return uid + pwd + " and " + errorMessage;
// for each entry found
while (results.hasMore())
SearchResult sr = (SearchResult);
Attributes attrs = sr.getAttributes();
if (attrs == null)
return errorMessage;
// For each attribute of the entry
for (NamingEnumeration ae = attrs.getAll(); ae.hasMore()
Attribute attr = (Attribute);
String id = attr.getID();
// for each value of the attribute
for(Enumeration vals = attr.getAll(); vals.hasMoreElements();
System.out.println(" " + id + ": " + vals.nextElement()));
return successMessage;
return successMessage;
catch(NamingException ne)
// handle any name/directory exceptions
//System.out.println("Authentication failed: " + ne.getMessage());
return "Authentication failed: " + ne.getMessage();
catch(Exception e)
// handle any other types of exceptions
//System.err.println("Non-naming error: " + e.getMessage());
return "Non-naming error: " + e.getMessage();
} // end of processAuthenticate
} // end of AuthenticateImpl

Any help would be greatly appreciated.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic