You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ja...@apache.org on 2006/02/20 14:42:21 UTC

svn commit: r379127 - /lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java

Author: jann
Date: Mon Feb 20 05:42:19 2006
New Revision: 379127

URL: http://svn.apache.org/viewcvs?rev=379127&view=rev
Log:
add support for ldap  referral

Modified:
    lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java

Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java?rev=379127&r1=379126&r2=379127&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/ldap/LDAPUser.java Mon Feb 20 05:42:19 2006
@@ -41,6 +41,7 @@
 import org.apache.log4j.Logger;
 
 import com.sun.jndi.ldap.LdapCtxFactory;
+import com.sun.jndi.ldap.LdapURL;
 
 /**
  * LDAP user.
@@ -68,6 +69,7 @@
     private static String USR_AUTH_TYPE_DEFAULT = "simple";
     private static String BASE_DN_PROP = "base-dn";
     private static String DOMAIN_NAME_PROP = "domain-name";
+    private static String HANDLE_REFERRALS_PROP = "handle-referrals";
 
     private String ldapId;
     private String ldapName;
@@ -369,6 +371,8 @@
 	if (authMethod != null && ! authMethod.equals("none")) {
 	    env.put(Context.SECURITY_PRINCIPAL, principal);
 	    env.put(Context.SECURITY_CREDENTIALS, credentials);
+        String referrals = defaultProperties.getProperty(HANDLE_REFERRALS_PROP);
+        if (referrals != null) env.put(Context.REFERRAL, referrals);
 	}
 
         DirContext ctx = new InitialLdapContext(env, null);
@@ -540,9 +544,13 @@
 		principal = entry.getName();
 		if (entry.isRelative()) {
 		    if (principal.length()>0){
-			principal = principal +","+ defaultProperties.getProperty(BASE_DN_PROP);
-		    }
-		}
+                principal = principal +","+ defaultProperties.getProperty(BASE_DN_PROP);
+                }
+            } else {
+                //if the item is found followin a referral an URL string is returned which can not be used as principal
+                LdapURL ldapurl = new LdapURL(principal);
+                principal = ldapurl.getDN();
+            }
 	    }
 	    else {
 		// 3. Principal is constructed from properties



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org