Announcement Announcement Module
Collapse
No announcement yet.
LDAP: error code 49 - Invalid Credentials Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LDAP: error code 49 - Invalid Credentials

    hi,

    i am getting that exception while using LdapTemplate.authenticate method.

    i am getting uid and password from JSP and on valid password the method return TRUE, but on wrong password, the throws exception :

    Exception :

    org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
    Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:2985)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2931) AndFilter filter = new AndFilter()
    .and(new EqualsFilter(LDAPEnum.OBJ_CLASS.getValue(), LDAPEnum.PERSON_CLASS.getValue()))
    .and(new EqualsFilter(LDAPEnum.UID.getValue(), uid));



    My Method :

    public Object authenticate(String uid, String password) {

    DistinguishedName dN = this.getNameForUser(uid);
    boolean authenticated = false;

    AndFilter filter = new AndFilter()
    .and(new EqualsFilter(LDAPEnum.OBJ_CLASS.getValue(), LDAPEnum.PERSON_CLASS.getValue()))
    .and(new EqualsFilter(LDAPEnum.UID.getValue(), uid));

    authenticated = ldapTemplate.authenticate(DistinguishedName.EMPTY_ PATH, filter.toString(), password);

    if(authenticated) {
    return this.getUserEntity(uid);
    }

    return null;
    }



    LDAPEnum Class :

    public enum LDAPEnum {
    O("o"),
    DC("dc"),
    OU("ou"),
    CN("cn"),
    UID("uid"),
    OBJ_CLASS("objectClass"),
    PERSON_CLASS("person");

    private final String value;
    private LDAPEnum(String value) {
    this.value = value;
    }
    public String getValue() {
    return value;
    }
    }


    Thats happen only when password is wrong. kindly give feedback,

    Thanks

  • #2
    Please provide the full stack trace.

    Comment


    • #3
      Any response

      I'm getting the same exception. Only happens when I supply wrong password!!
      template.authenticate(DistinguishedName.EMPTY_PATH , filter.toString(), password)


      javax.naming.AuthenticationException: [LDAP: error code 49 - NDS error: failed authentication (-669)]
      at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:3027)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2973)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2775)
      at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:268 9)
      at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:300)
      at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapC txFactory.java:187)
      at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Ldap CtxFactory.java:205)
      at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstanc e(LdapCtxFactory.java:148)
      at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext (LdapCtxFactory.java:78)
      at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:230)
      at javax.naming.InitialContext.initializeDefaultInitC tx(InitialContext.java:322)
      at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:352)
      at javax.naming.InitialContext.internalInit(InitialCo ntext.java:290)
      at javax.naming.InitialContext.init(InitialContext.ja va:312)
      at javax.naming.ldap.InitialLdapContext.<init>(Initia lLdapContext.java:103)
      at org.springframework.ldap.core.support.LdapContextS ource.getDirContextInstance(LdapContextSource.java :43)
      at org.springframework.ldap.core.support.AbstractCont extSource.createContext(AbstractContextSource.java :254)

      Comment


      • #4
        See This thread

        Authenticate with AuthenticationException

        http://forum.springsource.org/showthread.php?t=74996

        Comment

        Working...
        X