I\'m a college student. Now, i\'m doing a project that must use LDAP connection to authenticate the username and password of the user in log in process. So, my website is de
This is the important line: javax.naming.InvalidNameException: [LDAP: error code 34 - invalid DN]
You can look here: https://wiki.servicenow.com/index.php?title=LDAP_Error_Codes
for what 34 means, but it looks like the distinguished name you are trying to use is incorrect. It looks like your principal could be formatted incorrectly. See this guide from oracle on doing ldap authentication: http://docs.oracle.com/javase/jndi/tutorial/ldap/security/ldap.html
pay special attention to this part of it where they set up the environment entries:
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
env.put(Context.SECURITY_CREDENTIALS, "mysecret");
The "javax.naming.InvalidNameException: [LDAP: error code 34 - invalid DN] " in your stack trace is the key. Your LDAP server doesn't like the value you are sending it. I would suggest fully qualifying the user name, something like cn=username, ou=some_container, o=mycompany. The actual syntax will be driven by your LDAP server.