• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

LDAP Authentication

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I worked on LDAP authentication , and i used the following code, but i'm getting the error, i.e
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials] .
Pls solve this problem and provide the solution.
code is
String url="ldap://,ou=company name,o=organization name";
Hashtable environment =new Hashtable();
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL,"CN=" + username);
DirContext dircontext=new InitialDirContext(environment);
Attributes attributes=dircontext.getAttributes("CN=" + username);
String fullname=(String) attributes.get("givenname").get();
} catch(AuthenticationException ex) {out.println(ex);}
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the principal you are passing? It has to be the dn without the prefix "dn="
But I have seen this error only when the password is wrong. What's the LDAP server you are using? Also check passing an empty string for password.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic