Dilip D
Dilip D

Reputation: 565

ldap Authentication Error from java program

public static void main(String[] args)
{


    // Setup environment for authenticating

    Hashtable<String, String> environment = 
        new Hashtable<String, String>();

    environment.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

    environment.put(Context.PROVIDER_URL,"ldap://192.168.0.100:389");

    environment.put(Context.SECURITY_AUTHENTICATION,"simple");

    environment.put(Context.SECURITY_PRINCIPAL,"uid=dilip.duraiswamy,dc=xxxx,dc=local");

    environment.put(Context.SECURITY_CREDENTIALS,"xxxx");

    try
    {
        DirContext authContext = 
            new InitialDirContext(environment);

        // user is authenticated
        System.out.println("USER IS AUTHETICATED");

    }
    catch (AuthenticationException ex)
    {

        // Authentication failed
        System.out.println("AUTH FAILED : "+ex );

    }
    catch (NamingException ex)
    {
        ex.printStackTrace();
    }
}

Getting the error as javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580

Upvotes: 2

Views: 12842

Answers (1)

Bananas
Bananas

Reputation: 141

For the authentication, add the correct distinguished name.

This issue is usually observed if the DN is not specified correctly in the case when it has space or some special characters.

​Here 52e – represents invalid credential

http://www-01.ibm.com/support/docview.wss?uid=swg21290631

Upvotes: 1

Related Questions