Author: sebawagner
Date: Tue Apr 10 09:25:23 2012
New Revision: 1311655

URL: http://svn.apache.org/viewvc?rev=1311655&view=rev
Log:
Contributed patch from: OPENMEETINGS-144 When using openLDAP authentication, 
the source code uses the hardcoded 'uid' attribute to map logins and user DNs 
instead of the field_user_principal parameter

Modified:
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapAuthBase.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapLoginManagement.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapAuthBase.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapAuthBase.java?rev=1311655&r1=1311654&r2=1311655&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapAuthBase.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapAuthBase.java
 Tue Apr 10 09:25:23 2012
@@ -235,9 +235,10 @@ public class LdapAuthBase {
        /**
         * @param searchBase Ldap base to begin de SUB scope search for the 
userDN
         * @param searchFilter Ldap filter to search only for the specified 
loginame while looking for the userDN
+        * @param ldap_fieldname_user_principal ldap sttribute name that 
contains the user loginame
         * @return
         */
-       public HashMap<String, String> getUidCnHashMap(String searchBase, 
String searchFilter) {
+       public HashMap<String, String> getUidCnHashMap(String searchBase, 
String searchFilter, String ldap_fieldname_user_principal) {
                HashMap<String, String> uidCnDictionary = new HashMap<String, 
String>();
 
                SearchControls searchCtls = new SearchControls();
@@ -247,9 +248,12 @@ public class LdapAuthBase {
                        results = authContext.search(searchBase, searchFilter,  
searchCtls);
                        while (results.hasMore()) {
                                SearchResult searchResult = results.next();
+                               // 'cn' gets the name of the entry relative to 
searchbase for instance: "uid=user,ou=people"
+                               // The entry DN is found by appending the 
searchbase. For instance if searchbase 
+                               // is (dc=mydomain,dc=org), then 
DN="uid=user,ou=people,dc=mydomain,dc=org"
                                String cn = searchResult.getName();
                                Attributes attributes = 
searchResult.getAttributes();
-                               Attribute attrib = attributes.get("uid");
+                               Attribute attrib = 
attributes.get(ldap_fieldname_user_principal);
                                
                                if (attrib != null) {
                                        String uid = (String) attrib.get();

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapLoginManagement.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapLoginManagement.java?rev=1311655&r1=1311654&r2=1311655&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapLoginManagement.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/ldap/LdapLoginManagement.java
 Tue Apr 10 09:25:23 2012
@@ -395,7 +395,7 @@ public class LdapLoginManagement {
                        log.debug("LDAP server is OpenLDAP");
                        log.debug("LDAP search base: " + ldap_search_scope);
                        HashMap<String, String> uidCnDictionary = 
lAuth.getUidCnHashMap(
-                                       ldap_search_scope, ldap_search_filter);
+                                       ldap_search_scope, ldap_search_filter, 
ldap_fieldname_user_principal);
                        if (uidCnDictionary.get(user) != null) {
                                ldapUserDN = uidCnDictionary.get(user) + ","
                                                + ldap_search_scope;


Reply via email to