Commit 93a2b225 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Referrals are now being respected. JM-601

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3588 b35dd754-fafc-0310-a699-88a17e54d16e
parent 31e569d5
...@@ -322,6 +322,13 @@ public class LdapManager { ...@@ -322,6 +322,13 @@ public class LdapManager {
if (ldapDebugEnabled) { if (ldapDebugEnabled) {
env.put("com.sun.jndi.ldap.trace.ber", System.err); env.put("com.sun.jndi.ldap.trace.ber", System.err);
} }
if (connectionPoolEnabled) {
env.put("com.sun.jndi.ldap.connect.pool", "true");
}
if (followReferrals) {
env.put(Context.REFERRAL, "follow");
}
if (debug) { if (debug) {
Log.debug("Created context values, attempting to create context..."); Log.debug("Created context values, attempting to create context...");
} }
...@@ -358,6 +365,12 @@ public class LdapManager { ...@@ -358,6 +365,12 @@ public class LdapManager {
if (ldapDebugEnabled) { if (ldapDebugEnabled) {
env.put("com.sun.jndi.ldap.trace.ber", System.err); env.put("com.sun.jndi.ldap.trace.ber", System.err);
} }
if (connectionPoolEnabled) {
env.put("com.sun.jndi.ldap.connect.pool", "true");
}
if (followReferrals) {
env.put(Context.REFERRAL, "follow");
}
if (debug) { if (debug) {
Log.debug("Created context values, attempting to create context..."); Log.debug("Created context values, attempting to create context...");
} }
...@@ -493,8 +506,18 @@ public class LdapManager { ...@@ -493,8 +506,18 @@ public class LdapManager {
throw new UserNotFoundException("LDAP username lookup for " + username + throw new UserNotFoundException("LDAP username lookup for " + username +
" matched multiple entries."); " matched multiple entries.");
} }
//All other methods assume that userDN is not a full LDAP string.
//However if a referal was followed this is not the case. The
//following code converts a referral back to a "partial" LDAP string.
if (userDN.startsWith("ldap://")) {
userDN = userDN.replace("," + baseDN, "");
userDN = userDN.substring(userDN.lastIndexOf("/") + 1);
return userDN; return userDN;
} }
else {
return userDN;
}
}
catch (Exception e) { catch (Exception e) {
if (debug) { if (debug) {
Log.debug("Exception thrown when searching for userDN based on username '" + username + "'", e); Log.debug("Exception thrown when searching for userDN based on username '" + username + "'", e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment