aspose file tools*
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
Author

AD LDAP Authentication & Data Fetch Error.

vivek x. singh
Greenhorn

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 [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";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials, note using simple cleartext authentication
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);

//connect to my domain controller
env.put(Context.PROVIDER_URL,ldapURL);

try {

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

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

//Specify the search scope
searchCtls.setSearchScope(SearchControls.SUBTREE_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"};
searchCtls.setReturningAttributes(returnedAtts);

//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);
ctx.close();

}

catch (NamingException e) {
e.printStackTrace();
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
nentContext.java:322)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.c_search_nns(ComponentDi
rContext.java:171)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirCon
text.java:364)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
positeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
positeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.jav
a:238)
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/'


Vivek Singh
Sr. Software Engineerer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AD LDAP Authentication & Data Fetch Error.