Question

This is the following program which works fine for some ADS servers(deployed on 2008 server) but fails to connect to the AD server deployed on AD server(deployed on 2012 server). I am getting the following exception wgile connecting

[LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 2030, v23f0]

the same exception is occured while using JXplorer also.

Can any one help me on this.

import java.util.Hashtable;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;

public class TestLdap {

    public static void main(String[] args) {

        String base = "";  

        String filter = "(objectclass=*)";  

        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://example.com:389/dc=example,dc=com");  
        env.put(Context.SECURITY_AUTHENTICATION, "simple");  
        env.put(Context.SECURITY_PRINCIPAL, "test@example.com");  
        env.put(Context.SECURITY_CREDENTIALS, "secret");  
        try {  

            DirContext dc = new InitialDirContext(env);  

            SearchControls sc = new SearchControls();  
            sc.setSearchScope(SearchControls.OBJECT_SCOPE);  
            NamingEnumeration ne = null;  

            while (ne.hasMore()) {  

                SearchResult sr = (SearchResult) ne.next();  
                System.out.println(sr.toString()+"\n");  
            }  

            dc.close();  
        } catch (NamingException nex) {  

            System.err.println("Error: " + nex.getMessage());  
        } 

    }

}
Was it helpful?

Solution

Couple of ideas:

  1. Did you check you have network access to your new AD server on port 389?

  2. Are you sure you credentials that you are specifying are valid AD credentials on the new server as well

  3. Also try accessing the global AD catalog on port 3268 and see if you have better luck there(just change the port in your code, and retry)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top