I'm using the Netscape directory SDK with the example out of the users
manual to search an ldap searver. This server has referrals in it of the
structure ref: ldap://server:port/ou=xxx,o=yyy
but the example only returns ldap://server:port of the url and I can't get
the DN using getDN(). Here's the code on the example, any help would be
benificial. I'd like to know how to get the dn part of the referral back.
Thanks,
Mark
public static void main( String[] args )
{
/* Step 1: Create a new connection. */
LDAPConnection ld = new LDAPConnection();
try {
/* Step 2: Connect to an LDAP server. */
ld.connect( "lorien.fas.harvard.edu", LDAPv3.DEFAULT_PORT );
ld.authenticate( "ou=ummu,ou=fed,o=vdc","secret" );
LDAPSearchResults results = ld.search( "o=vdc",
netscape.ldap.LDAPv3.SCOPE_SUB, "(objectClass=*)", null, false );
/* Print the DNs of the matching entries. */
while ( results.hasMoreElements() ) {
LDAPEntry entry = null;
try {
entry = results.next();
System.out.println( entry.getDN() );
} catch ( LDAPReferralException e ) {
System.out.println( "Search references: " );
LDAPUrl refUrls[] = e.getURLs();
for ( int i=0; i < refUrls.length; i++ ) {
System.out.print( "\t" + refUrls[i].getUrl() );
System.out.println( " " + refUrls[i].toString() );
}
continue;
} catch ( LDAPException e ) {
System.out.println( "Error: " + e.toString() );
continue;
}
}
} catch( LDAPException e ) {
System.out.println( "Error: " + e.toString() );
}
/* Step 5: Disconnect from the server when done. */
try {
ld.disconnect();
} catch( LDAPException e ) {
System.out.println( "Error: " + e.toString() );
System.exit(1);
}
System.exit(0);
}
Mark R. Diggory
Software Engineer
Harvard-MIT Data Center
G-6 Littauer Center, North Yard
Harvard University
Cambridge, MA 02138
(617)496-7246