OK....nothing shows up in Firefox (Tools/Error Console). I also tried Firebug and did not see anything there. I'm posting my code below, and I know I'm getting an error because I'm seeing the "Caught Error: " in my output window, which is in the catch section of the try block. It doesn't tell me what the problem was though. Also the LDAP server logs do not show any binds....so I haven't even gotten to the point where I successfully connect yet.
I get the following in my output window.
Hello BEGIN
(DN of the auth user)
Caught Error:
Hello END
Code:
PrintWriter output = response.getWriter();
output.println("Hello BEGIN\n\n");
output.println(dn);
Properties env = new Properties();
env.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.LdapCtxFactory" );
env.put("java.naming.ldap.version", "3");
env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName + "/");
env.put( Context.SECURITY_AUTHENTICATION, "simple");
env.put( Context.SECURITY_PRINCIPAL, dn );
env.put( Context.SECURITY_CREDENTIALS, pass);
try {
//Create the initial directory context
DirContext ctx = new InitialDirContext( env );
//Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("uid=username, ou=people");
//Find the surname attribute ("sn") and print it
//System.out.println(mySn);
response.setContentType("text/html");
output.println("Hello MIDDLE");
output.println("sn: "+ attrs.get("sn").get());
}
catch (NamingException e){
//Authentication Failed
output.println("Caught Error: ");
}
output.println("Hello END");