File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes AD LDAP Authentication & Data Fetch Error. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "AD LDAP Authentication & Data Fetch Error." Watch "AD LDAP Authentication & Data Fetch Error." New topic

AD LDAP Authentication & Data Fetch Error.

vivek x. singh

Joined: Jun 10, 2004
Posts: 1
Hi All,

I am just bouncing my head from past 2-3 days to resolve AD-LDAP related issue. In Win2000 & Exchange2000 setup, I am running my code either it is running with out giving any results [data] or throwing exception. Plz view the code & provide clue/code. Thanx a lot in advance.

Vivek Singh []

package rmi;

import java.util.Hashtable;
import javax.naming.*;
import javax.naming.ldap.*;

public class member{
public static void main (String[] args){

Hashtable env = new Hashtable();
String adminName = "Ex2kuser";
String adminPassword = "pawrd";
String ldapURL = "ldap://";
//set security credentials, note using simple cleartext authentication

//connect to my domain controller

try {

//Create the initial directory context
LdapContext ctx = new InitialLdapContext(env,null);

//Create the search controls
SearchControls searchCtls = new SearchControls();

//Specify the search scope

//specify the LDAP search filter
String searchFilter = "(&(objectClass=group)(CN=*))";

//Specify the Base for the search
String searchBase = "DC=catelogi-mes,DC=com";

//initialize counter to total the group members
int totalResults = 0;

//Specify the attributes to return
String returnedAtts[]={"member"};

//Search for objects using the filter
NamingEnumeration answer =, searchFilter, searchCtls);

//Loop through the search results
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult);

System.out.println(">>>" + sr.getName());

//Print out the members

Attributes attrs = sr.getAttributes();
if (attrs != null) {

try {
for (NamingEnumeration ae = attrs.getAll();ae.hasMore() {
Attribute attr = (Attribute);
System.out.println("Attribute: " + attr.getID());
for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {

System.out.println(" " + totalResults + ". " +;


catch (NamingException e){
System.err.println("Problem listing members: " + e);


System.out.println("Total members: " + totalResults);


catch (NamingException e) {
System.err.println("Problem searching directory: " + e);

====>> This code is running fine but not giving/fetching any results and when i m replacing line

String searchBase = "DC=catelogi-mes,DC=com";
====>>String searchBase = "DC=catelogi-mes,DC=com/";

Then it is showing exception like

javax.naming.PartialResultException: [LDAP: error code 10 - 0000202B: RefErr: DS
ID-031006D9, data 0, 1 access points
ref 1: ''
]; remaining name 'DC=catelogi-mes,DC=com/'
at com.sun.jndi.ldap.LdapCtx.processReturnCode(
at com.sun.jndi.ldap.LdapCtx.processReturnCode(
at com.sun.jndi.ldap.LdapCtx.c_lookup(
at com.sun.jndi.toolkit.ctx.ComponentContext.c_processJunction_nns(Compo
at com.sun.jndi.toolkit.ctx.ComponentDirContext.c_search_nns(ComponentDi
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirCon
at rmi.member.main(
Problem searching directory: javax.naming.PartialResultException: [LDAP: error c
ode 10 - 0000202B: RefErr: DSID-031006D9, data 0, 1 access points
ref 1: ''
]; remaining name 'DC=catelogi-mes,DC=com/'

Vivek Singh
Sr. Software Engineerer
I agree. Here's the link:
subject: AD LDAP Authentication & Data Fetch Error.
It's not a secret anymore!