james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1665049 - /james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
Date Sun, 08 Mar 2015 16:40:47 GMT
Author: eric
Date: Sun Mar  8 16:40:46 2015
New Revision: 1665049

URL: http://svn.apache.org/r1665049
Log:
LDAP group authentication filter to authenticate users, patch contributed by Robert Munn (JAMES-1569)

Modified:
    james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java

Modified: james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java?rev=1665049&r1=1665048&r2=1665049&view=diff
==============================================================================
--- james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
(original)
+++ james/server/trunk/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
Sun Mar  8 16:40:46 2015
@@ -41,6 +41,7 @@ import javax.naming.ldap.LdapContext;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.lang.StringUtils;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.LogEnabled;
 import org.apache.james.user.api.UsersRepository;
@@ -252,6 +253,12 @@ public class ReadOnlyUsersLDAPRepository
     private String userObjectClass;
 
     /**
+     * The value of this field is taken from the configuration attribute "filter".
+     * This is the search filter to use to find the desired user. 
+     */
+    private String filter;
+    
+    /**
      * This is the LDAP context/sub-context within which to search for user
      * entities. The value of this field is taken from the configuration
      * attribute "userBase".
@@ -352,6 +359,9 @@ public class ReadOnlyUsersLDAPRepository
         }
         restriction = new ReadOnlyLDAPGroupRestriction(restrictionConfig);
 
+        //see if there is a filter argument
+        filter = configuration.getString("[@filter]");
+
     }
 
     /**
@@ -534,7 +544,14 @@ public class ReadOnlyUsersLDAPRepository
 
       StringBuilder builderFilter = new StringBuilder("(&(");
       builderFilter.append(userIdAttribute).append("=").append(name).append(")")
-                   .append("(objectClass=").append(userObjectClass).append("))");
+                   .append("(objectClass=").append(userObjectClass).append(")");
+
+     if(StringUtils.isNotEmpty(filter)){
+    	 builderFilter.append(filter).append(")");
+    	 }
+     else{
+    	 builderFilter.append(")");
+     }
 
       NamingEnumeration<SearchResult> sr = ldapContext.search(userBase, builderFilter.toString(),
           sc);
@@ -744,4 +761,4 @@ public class ReadOnlyUsersLDAPRepository
         return false;
     }
 
-}
\ No newline at end of file
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message