Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LDAPReferralException - how to reterive multiple referrals returned by the server.

 
java Prentice
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

On OpenLDAP Server setup we have done referral setting for ldapsrv2 and ldapsrv3 on ldapsrv1

Following are the scenarios that were examine using ldap client (on ldapsrv2) for connection to ldapsrv1 (192.168.146.10):
Scenario-1:
---------------
1. Using ‘ldapsearch’ command searched the users on ldapsrv1 with search baseDN: dc=nhst,dc=com 2. Returned the user info and returned referral to ldapsrv2 as search type is sub-tree search i.e.
Ref: ldap://ldapsrv2/dc=child,dc=nhst,dc=com??sub
Scenario-2:
---------------
1. Using ‘ldapsearch’ command searched the users on ldapsrv2 with search baseDN: dc=nhst,dc=com 2. Returned no user info but returned referral to ldapsrv2 as search type is sub-tree search and also referral to ldapsrv3 as this ref is added under dummy sub-tree entry dc=child2,dc=hcl,dc=com i.e.
Ref: ldap://ldapsrv2/dc=child,dc=nhst,dc=com??sub
Ref: ldap://ldapsrv3/dc=nec,dc=com??sub

Issue :

I want to build same client in java for authentication openldap users using LdapContextFactory, but when i set the context.referral as throw. it only return one referral

catch (LdapReferralException e) {
String url = e.getReferralInfo().toString();
boolean moreRefferals = true;
while (moreRefferals) {
try {
//getcred(env);
String[] urls = url.split("/ou=people,");
String provider_url = urls[0];
String searc_base = urls[1].replace("??sub", "").trim();
env.put(Context.SECURITY_PRINCIPAL, "cn=Manager," + searc_base);
env.put(Context.PROVIDER_URL, provider_url);
try {
ctx = new InitialDirContext(env);
final NamingEnumeration<SearchResult> answer = ctx
.search(searc_base, searchFilter,
searchCtls);
while (answer.hasMore()) {
answer.next();
System.out.println("success");
moreRefferals = false;
}
} catch (LdapReferralException e1) {
url = e.getReferralInfo().toString();
e.retryReferral();
}
} catch (AuthenticationException ne) {
System.out.println("Authentication failed: " + e);

return false;

} catch (NamingException ne) {
e.skipReferral();
System.out.println("Referral failed: " + ne);
}
}
even if i use e.retryReferral().

Please suggest me any other way by which i can get referrals returned by the server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic