Hi ,


I am unable to connect to LDAP server using JNDI. I get the exception as :

Naming Exception :[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0_


Please help me how i can resolve this issue.

My Client program to connect to LDAP server is below:

ublic static void main(String args[])

{

Hashtable env = new Hashtable();





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

env.put(Context.PROVIDER_URL, "ldap://url:389/ou=system");

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

env.put(Context.SECURITY_PRINCIPAL, "uid=,ou=system,dc=,dc=,c=,o=");

env.put(Context.SECURITY_CREDENTIALS, "");

DirContext ctx = null;

NamingEnumeration results = null;

try {

ctx = new InitialDirContext(env);

SearchControls controls = new SearchControls();

controls.setSearchScope(SearchControls.SUBTREE_SCOPE);

results = ctx.search("", "(objectclass=person)", controls);

while (results.hasMore()) {

SearchResult searchResult = (SearchResult) results.next();

Attributes attributes = searchResult.getAttributes();

Attribute attr = attributes.get("cn");

String cn = (String) attr.get();

System.out.println(" Person Common Name = " + cn);

}

} catch (NamingException e) {

System.out.println("Naming Exception :"+e.getMessage());

throw new RuntimeException(e);

} finally {

if (results != null) {

try {

results.close();

} catch (Exception e) {

}

}

if (ctx != null) {

try {

ctx.close();

} catch (Exception e) {

}

}
Thanks in advance,
Ravi