I'm trying to authenticate to LDAP via JSP-JNDI on Tomcat 7. I'm using maven to organize and compile, and here's the code of the .jsp file:
<html>
<body>
<h2>Bind</h2>
<%
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:1389");
DirContext ctx = new InitialDirContext(env);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL,"cn=Manager");
env.put(Context.SECURITY_CREDENTIALS,"pwd");
DirContext ctx = new InitialDirContext(env);
%>
</body>
</html>
When I connect to localhost:8080/AddressBook/ the server says that every variable "cannot be resolved to a variable": Hashtable,Context.PROVIDER_URL,DirContext,InitialDirContext etc. I can immagine it could be a simple error. Do I have to import some class? If I have to where i have to specify it?
I reached this point now, this is my JSP file.
It looks like it works. My second step is to listen all the entries I have on my LDAP directory. (LDAP is full and completely functional on my machine) Any advice ? Should I use a main or a class ?