Exactly where do you passon the username to the LDAP server?
I am not proficient in JSP, so ...
my best guess would be:
BASE_DN = "DC=myorg, DC=local"; // depends on you LDAP ...
env.put(Context.SECURITY_P
RINCIPAL, userName+", "+BASE_DN);
You might need an "DN:" in fron I am not sure of that.
Here is an elaborate example: (with checks for roles).
http://www.codase.com/search/display?file=L2dlbnRvbzIvdmFyL3RtcC9yZXBvcy9zb3VyY2Vmb3JnZS9qYm9zcy9qYm9zcy1qZGs1LXNlYW0tNDAzUkMyLXNyY190YXJfZ3ovamJvc3MtamRrNS1zZWFtLTQwM1JDMi1zcmMvc2VjdXJpdHkvc3JjL21haW4vb3JnL2pib3NzL3NlY3VyaXR5L2F1dGgvc3BpL0xkYXBFeHRMb2dpbk1vZHVsZS5qYXZh&lang=java&off=13920+13953+