• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Himai Minh

AD LDAP Authentication & Data Fetch Error.

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [viveklib@yahoo.com]

package rmi;

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

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

Hashtable env = new Hashtable();
String adminName = "Ex2kuser";
String adminPassword = "pawrd";
String ldapURL = "ldap://wcaxte05.catelogi-mes.catelogi.com:389";
//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 = ctx.search(searchBase, searchFilter, searchCtls);

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

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)ae.next();
System.out.println("Attribute: " + attr.getID());
for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {

System.out.println(" " + totalResults + ". " + e.next());


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: 'catelogi-mes.com'
]; remaining name 'DC=catelogi-mes,DC=com/'
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2699)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2616)
at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:931)
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 com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
at javax.naming.directory.InitialDirContext.search(InitialDirContext.jav
at rmi.member.main(member.java:52)
Problem searching directory: javax.naming.PartialResultException: [LDAP: error c
ode 10 - 0000202B: RefErr: DSID-031006D9, data 0, 1 access points
ref 1: 'catelogi-mes.com'
]; remaining name 'DC=catelogi-mes,DC=com/'
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic