Link to home
Create AccountLog in
Avatar of srikotesh
srikotesh

asked on

javax.naming.AuthenticationException

Hi Expets,

I am trying to connect ldap active directory path

Exception:
==========

Exception in thread "main" javax.naming.AuthenticationException:
 [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903CF,
 comment: AcceptSecurityContext error, data 52e, v2580

PLEASE FINE THE BELOW CODE AND SUGGEST WHAT IS WRONG IN MY CODE


public class AdSearchExample {
    
    /**
     * @param args
     * @return
     * @throws NamingException
     */
    public static InitialDirContext getDirContext() throws NamingException {
        Hashtable<String, String> env = new Hashtable<String, String>();        
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");      
        env.put(Context.PROVIDER_URL,"ldap://host:portno/");
        env.put(Context.REFERRAL, "follow");
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, "CN=SRI RAO,OU=PRAC,OU=Users,OU=MindTree Bangalore,OU=Asia Pacific,DC=mindtree,DC=com");
        env.put(Context.SECURITY_CREDENTIALS, "welocome@123");
        System.out.println("env" +env);
        return new InitialDirContext(env);       
    }
    
    public static void main(String args[]) throws NamingException{

        DirContext context = getDirContext();

}

}

Open in new window

SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.