[Date Prev][Date Next] [Chronological] [Thread] [Top]

Searching with Netscape LDAP JDK (ITS#306)

System: Linux 2.2.12
glibc: 2.1.2
gcc: egcs-2.90.29 980515 (egcs-1.0.3 release)
openLDAP: 1.2.7

I have just updated my openldap installation from 1.2 to 1.2.7.  In doing so, 
it appears that the search function operates a little differently in my Java 
program.  I have included a fragment of it below.  The search uses the jars 
provided in the Netscape LDAP jdk (ldapfilt.jar and ldapjdk.jar).

Against the old openLDAP install (1.2), the search worked as expected, pulling 
"Barbara Jensen" and "Bjorn Jensen" out of the test database.  However, no 
common names are retrieved during a search against the new installation. In 
order to achieve the same results, I have to modify the search criteria.  The 
search works if I change the string to:
String searchFilter = "(sn=Jensen*)";

Is this a bug or is there something wrong with the original Java program?


Jon Barnett

String baseDN = "o=University of Michigan, c=US";
String searchFilter = "(sn=Jensen)";
String getAttributes[] = { "cn" };
int searchScope = LDAPv2.SCOPE_SUB;
println("Starting LDAP");
LDAPConnection ld = new LDAPConnection();
	println("Connecting to server");
	println("Authenticating (not)...");
	println("Searching ...");
	LDAPSearchResults results = ld.search(baseDN, searchScope, searchFilter, 
getAttributes, false);
	println("Printing list ...");
	while (results.hasMoreElements())
		LDAPEntry findEntry = null;
			findEntry = results.next();
			LDAPAttribute attribute = findEntry.getAttribute("cn");
			Enumeration enumValues = attribute.getStringValues();
			String commonName = (String)enumValues.nextElement();
			println("Common name: " + commonName);
		catch (LDAPReferralException e)
			println("Failed ...");
catch (LDAPException e)
	println("Failed ...");