• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Webapp and LDAP authentication

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to authenticate user and password in a form of my web application on LDAP server.

For do this, I wrote:

Hashtable<String,String> env = new Hashtable<String,String>(4);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://......:389/DC=.....,DC=....");
env.put(Context.SECURITY_PRINCIPAL, userid);// User
env.put(Context.SECURITY_CREDENTIALS, password);// Password

try {
new InitialDirContext(env);
log.info("User " + userid + " authenticated in LDAP mode");
} catch (AuthenticationException e) {
log.error("User " + userid + " authentication failed");
}

It works... BUT only for a few users! For others, existent and with valid password, the code throws an exception!

Access to Context is the same thing to verify password correctness? If they are different, I need another piece of code for the second thing?

Thanks
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic