We help IT Professionals succeed at work.
Get Started

javax.naming.AuthenticationException

srikotesh
srikotesh asked
on
151 Views
Last Modified: 2016-09-10
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

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE