tdraier     2005/12/14 18:18:07 CET

  Modified files:
    core/src/java/org/jahia/hibernate/manager 
                                              JahiaGroupManager.java 
    core/src/java/org/jahia/services/usermanager 
                                                 
JahiaGroupManagerLDAPProvider.java 
                                                 JahiaLDAPGroup.java 
                                                 JahiaLDAPUser.java 
                                                 
JahiaUserManagerLDAPProvider.java 
    core/src/webapp/WEB-INF/etc/ldap groups.ldap.properties 
                                     users.ldap.properties 
  Log:
  merged missing bugfixes from 4.1, fixed npe when using ldap groups
  
  Revision  Changes    Path
  1.7       +3 -0      
jahia/core/src/java/org/jahia/hibernate/manager/JahiaGroupManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/hibernate/manager/JahiaGroupManager.java.diff?r1=1.6&r2=1.7&f=h
  1.16      +114 -62   
jahia/core/src/java/org/jahia/services/usermanager/JahiaGroupManagerLDAPProvider.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/usermanager/JahiaGroupManagerLDAPProvider.java.diff?r1=1.15&r2=1.16&f=h
  1.8       +28 -7     
jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPGroup.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPGroup.java.diff?r1=1.7&r2=1.8&f=h
  1.11      +11 -0     
jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPUser.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPUser.java.diff?r1=1.10&r2=1.11&f=h
  1.18      +13 -5     
jahia/core/src/java/org/jahia/services/usermanager/JahiaUserManagerLDAPProvider.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/usermanager/JahiaUserManagerLDAPProvider.java.diff?r1=1.17&r2=1.18&f=h
  1.4       +10 -4     
jahia/core/src/webapp/WEB-INF/etc/ldap/groups.ldap.properties
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/ldap/groups.ldap.properties.diff?r1=1.3&r2=1.4&f=h
  1.5       +3 -3      
jahia/core/src/webapp/WEB-INF/etc/ldap/users.ldap.properties
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/ldap/users.ldap.properties.diff?r1=1.4&r2=1.5&f=h
  
  
  
  Index: JahiaGroupManager.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/hibernate/manager/JahiaGroupManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JahiaGroupManager.java    6 Oct 2005 15:56:03 -0000       1.6
  +++ JahiaGroupManager.java    14 Dec 2005 17:18:06 -0000      1.7
  @@ -195,6 +195,9 @@
           }
           if (cache != null) {
               int keys = groupKey.indexOf(":");
  +            if (keys == -1) {
  +                return null;
  +            }
               entryKey = CacheAdvice.toGroupCacheKey(new 
Object[]{CACHE_KEY_GROUPPREFIX + groupKey.substring(0,keys),
                                                                                
                               CACHE_KEY_SITEPREFIX + 
groupKey.substring(keys+1)});
               group = (JahiaGroup) cache.get(entryKey);
  
  
  
  Index: JahiaGroupManagerLDAPProvider.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/usermanager/JahiaGroupManagerLDAPProvider.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JahiaGroupManagerLDAPProvider.java        6 Oct 2005 15:56:06 -0000       
1.15
  +++ JahiaGroupManagerLDAPProvider.java        14 Dec 2005 17:18:06 -0000      
1.16
  @@ -112,6 +112,8 @@
       private static String PUBLIC_BIND_DN_PROP = "groups.ldap.public.bind.dn";
       private static String PUBLIC_BIND_PASSWORD_PROP = 
"groups.ldap.public.bind.password";
   
  +    private static String PRELOAD_GROUP_MEMBERS = "groups.ldap.preload";
  +
       private static String SEARCH_ATTRIBUTE_PROP = 
"groups.ldap.search.attribute";
       private static String SEARCH_NAME_PROP = "groups.ldap.search.name";
       private static String GROUP_OBJECTCLASS_ATTRIBUTE = 
"groups.ldap.search.objectclass";
  @@ -130,7 +132,7 @@
        * not always a DN or named as a DN...
        */
       private static String SEARCH_USER_ATTRIBUTE_NAME = 
"groups.ldap.members.user.attibute.map";
  -    
  +
       private Properties ldapProperties = null;
   
       private DirContext publicCtx = null;
  @@ -289,7 +291,7 @@
                       DEFAULT_CONFIGURATION_FILE +
                       ", limiting to " +
                       this.ldapProperties.getProperty 
(SEARCH_COUNT_LIMIT_PROP) +
  -                    " first results...", slee);
  +                    " first results...");
           } catch (NamingException ne) {
               logger.warn ("JNDI warning",ne);
               invalidatePublicCtx ();
  @@ -327,6 +329,14 @@
           if (! (user instanceof JahiaLDAPUser)) {
               return new Vector();
           }
  +
  +        Vector result = ((JahiaLDAPUser)user).getGroups();
  +        if (result != null) {
  +            return result;
  +        }
  +
  +        result = new Vector ();
  +
           StringBuffer filterBuffer = new StringBuffer ();
           filterBuffer.append ("(&(objectclass=");
           filterBuffer.append (ldapProperties.getProperty 
(JahiaGroupManagerLDAPProvider.
  @@ -348,20 +358,13 @@
                       SEARCH_NAME_PROP),
                       filterBuffer.toString (),
                       searchCtl);
  -             } catch (NamingException e) {
  -            logger.warn (e);
  -            invalidatePublicCtx ();
  -            return new Vector ();
  -        }
  -        Vector result = new Vector ();
  -        try {
               while (answer.hasMore ()) {
                   String groupKey = ((SearchResult) answer.nextElement ()).
                           getAttributes ().
                           get (ldapProperties.getProperty (
                                   SEARCH_ATTRIBUTE_PROP)).get ().
                           toString ();
  -                result.add (groupKey);
  +                result.add ("{ldap}"+groupKey);
                   logger.debug ("groupKey=" + groupKey);
               }
           } catch (NamingException e) {
  @@ -371,17 +374,57 @@
           }
   
           // Now look for dynamic groups
  -        List v = getGroupList();
  -        for (Iterator iterator = v.iterator(); iterator.hasNext();) {
  -            String groupKey = (String) iterator.next();
  -            JahiaLDAPGroup jahiaLDAPGroup = (JahiaLDAPGroup) 
lookupGroup(groupKey);
  -            if (jahiaLDAPGroup.isDynamic()) {
  -                if (jahiaLDAPGroup.isMember(user)) {
  -                    result.add(groupKey);
  +        filterBuffer = new StringBuffer ();
  +        filterBuffer.append ("(objectclass=");
  +        filterBuffer.append (ldapProperties.getProperty 
(JahiaGroupManagerLDAPProvider.
  +                DYNGROUP_OBJECTCLASS_ATTRIBUTE, "groupOfURLs"));
  +        filterBuffer.append (")");
  +
  +        searchCtl = new SearchControls ();
  +        searchCtl.setSearchScope (SearchControls.SUBTREE_SCOPE);
  +        answer = null;
  +
  +        try {
  +            answer = getPublicContext (true).search 
(ldapProperties.getProperty (
  +                    SEARCH_NAME_PROP),
  +                    filterBuffer.toString (),
  +                    searchCtl);
  +
  +            while (answer.hasMore ()) {
  +                SearchResult sr = (SearchResult) answer.nextElement ();
  +                Attributes attr = sr.getAttributes ();
  +                String groupKey = attr.
  +                        get (ldapProperties.getProperty (
  +                                SEARCH_ATTRIBUTE_PROP)).get ().
  +                        toString ();
  +
  +                logger.debug ("groupKey=" + groupKey);
  +                NamingEnumeration answer2 = null;
  +                Attribute attribute = attr.get (ldapProperties.getProperty 
(DYNGROUP_MEMBERS_ATTRIBUTE, "memberurl"));
  +                if (attribute != null) {
  +                    answer2 = attribute.getAll ();
  +                    while (answer2.hasMore ()) {
  +                        String url = (String)answer2.next ();
  +                        Properties p = new Properties();
  +                        p.put("ldap.url", url);
  +                        p.put("user.key", 
removeKeyPrefix(user.getUserKey()));
  +                        Set t = getUserManagerProvider().searchUsers(0,p);
  +                        if (!t.isEmpty()) {
  +                            result.add("{ldap}"+groupKey);
  +                            if (answer2.hasMore()) {
  +                                answer2.close();
  +                            }
  +                            break;
  +                        }
  +                    }
                   }
               }
  +        } catch (NamingException e) {
  +            logger.warn (e);
  +            invalidatePublicCtx ();
  +            return new Vector ();
           }
  -
  +        ((JahiaLDAPUser)user).setGroups(result);
           return result;
       }
   
  @@ -411,7 +454,7 @@
                       DEFAULT_CONFIGURATION_FILE +
                       ", limiting to " +
                       this.ldapProperties.getProperty 
(SEARCH_COUNT_LIMIT_PROP) +
  -                    " first results...", slee);
  +                    " first results...");
           } catch (NamingException ne) {
               logger.warn ("JNDI warning",ne);
               invalidatePublicCtx ();
  @@ -450,10 +493,10 @@
                if (group == null) {
                        // 2004-23-07 : use wrappers
                JahiaGroupWrapper jgw = (JahiaGroupWrapper) mGroupCache.get 
("k"+groupKey);
  -             if (jgw == null) {              
  +             if (jgw == null) {
                    //logger.debug(" group with key=" + tmpGroupKey + " is not 
found in cache");
                    group = lookupGroupInLDAP (removeKeyPrefix(groupKey));
  -     
  +
                    if (group != null) {
                                        /* 2004-16-06 : update by EP
                                        new cache to populate : cross providers 
... */
  @@ -593,7 +636,7 @@
                        group = jgw.getGroup();
                }
                }
  -             
  +
           return group;
       }
   
  @@ -648,7 +691,7 @@
                       DEFAULT_CONFIGURATION_FILE +
                       ", limiting to " +
                       this.ldapProperties.getProperty 
(SEARCH_COUNT_LIMIT_PROP) +
  -                    " first results...", slee);
  +                    " first results...");
           } catch (PartialResultException pre) {
               logger.warn (pre);
           } catch (NamingException ne) {
  @@ -731,7 +774,7 @@
           }
           return publicCtx;
       }
  -    
  +
       /**
        * EP : 2004/07/05
        */
  @@ -744,10 +787,10 @@
                } catch (NullPointerException npe) {
                        logger.debug ("Reconnection is required... ", npe);
                }
  -             
  +
        return false;
       }
  -    
  +
       private DirContext connectToPublicDir ()
               throws NamingException {
           // EP : 2004/29/06 : implement reconnection mechanism on ldap...
  @@ -758,7 +801,7 @@
                logger.debug("connecting to all public dir for groups");
                return connectToAllPublicDir();
           }
  -        
  +
           // Identify service provider to use
           logger.debug ("Attempting connection to LDAP repository on " +
                   ldapProperties.getProperty (LDAP_URL_PROP) + "...");
  @@ -785,7 +828,7 @@
   
       private DirContext connectToAllPublicDir ()
               throws NamingException {
  -        DirContext ctx = null;               
  +        DirContext ctx = null;
        TreeSet servers = ((JahiaGroupManagerRoutingService)ServicesRegistry
                                                .getInstance()
                                                .getJahiaGroupManagerService())
  @@ -795,16 +838,16 @@
                ServerBean sb = (ServerBean) ite.next();
                String sbUrl = (String)sb.getPublicConnectionParameters()
                                        .get(Context.PROVIDER_URL);
  -                                     
  +
                int tryNumber = 1;
                while (tryNumber <= sb.getMaxReconnection()) {
                        // Identify service provider to use
  -                     logger.debug ("Attempting connection " 
  -                                             + tryNumber 
  -                                             + " to LDAP repository on " 
  +                     logger.debug ("Attempting connection "
  +                                             + tryNumber
  +                                             + " to LDAP repository on "
                                                + sbUrl
                                                + "...");
  -                                             
  +
                        // Create the initial directory context
                        try {
                                ctx = new InitialDirContext 
(sb.getPublicConnectionParameters());
  @@ -814,20 +857,20 @@
                                // exception while athenticating, forward the 
exception...
                                return null;
                        } catch (NamingException ne) {
  -                             // all others exception lead to try another 
connection... 
  +                             // all others exception lead to try another 
connection...
                                logger.error("Erreur while getting public 
context on " + sbUrl, ne);
                        }
                        tryNumber++;
                }
        }
  -     
  +
        if (ctx == null) {
                throw new NamingException("All servers used without 
success...");
        }
  -     
  +
           return ctx;
       }
  -    
  +
       /**
        * Retrieves groups from the LDAP public repository.
        *
  @@ -922,6 +965,9 @@
                       ldapProperties.getProperty (SEARCH_NAME_PROP),
                       filterString.toString (),
                       searchCtl);
  +        } catch (javax.naming.NoInitialContextException nice) {
  +            logger.warn("Reconnection required", nice);
  +            return getGroups(getPublicContext(true), filters);
           } catch (javax.naming.CannotProceedException cpe) {
               logger.warn("Reconnection required", cpe);
               return getGroups(getPublicContext(true), filters);
  @@ -1002,23 +1048,28 @@
               // FIXME : Quick hack for merging Jahia DB group properties with 
LDAP group
               mapDBToJahiaProperties (groupProps, usingGroupKey);
               boolean dynamic = 
groupProps.getProperty("objectClass").indexOf(ldapProperties.getProperty 
(JahiaGroupManagerLDAPProvider.DYNGROUP_OBJECTCLASS_ATTRIBUTE, "groupOfURLs")) 
!= -1;
  -            Hashtable members = null;
  -            try {
  -                members = getGroupMembers (sr, dynamic);
  -            } catch (NamingException ne) {
  -                logger.warn ("JNDI warning",ne);
  -            }
               try {
  +                if (ldapProperties.getProperty(PRELOAD_GROUP_MEMBERS, 
"true").equalsIgnoreCase("true")) {
  +                    Hashtable members = null;
  +                    try {
  +                        members = getGroupMembers (sr, dynamic);
  +                    } catch (NamingException ne) {
  +                        logger.warn ("JNDI warning",ne);
  +                    }
   
  -                group = new JahiaLDAPGroup (0, usingGroupKey, usingGroupKey, 
0,
  -                        members,
  -                        groupProps, dynamic);
  +                    group = new JahiaLDAPGroup (0, usingGroupKey, 
usingGroupKey, 0,
  +                            members,
  +                            groupProps, dynamic, true, this);
  +                } else {
  +                    group = new JahiaLDAPGroup (0, usingGroupKey, 
usingGroupKey, 0,
  +                            new Hashtable(),
  +                            groupProps, dynamic, false, this);
  +                }
                   return group;
               } catch (JahiaException e) {
                   logger.warn (e);
                   return null;
               }
  -
           } else {
               logger.debug ("Ignoring entry " + sr.getName () +
                       " because it has no valid " +
  @@ -1105,9 +1156,9 @@
       private JahiaLDAPGroup lookupGroupInLDAP (String groupKey) {
           JahiaLDAPGroup group = null;
           Enumeration groupEnum = nonExistentGroups.elements ();
  -        
  +
           logger.debug("lookupGroupInLDAP :: " + groupKey);
  -        
  +
           //FIXME: lousy solution for avoiding the over-querying of the ldap 
for non-existent groups...
           while (groupEnum.hasMoreElements ()) {
               if (groupKey.indexOf (groupEnum.nextElement () + ":") != -1)
  @@ -1126,7 +1177,7 @@
                       DEFAULT_CONFIGURATION_FILE +
                       ", limiting to " +
                       this.ldapProperties.getProperty 
(SEARCH_COUNT_LIMIT_PROP) +
  -                    " first results...", slee);
  +                    " first results...");
               group = null;
   
           } catch (PartialResultException pre) {
  @@ -1280,7 +1331,7 @@
       }
   
       public void stop() {}
  -    
  +
       /**
        * Modified by EP : 2004-18-06
        * Changes the way to retrieve groups members.
  @@ -1303,15 +1354,15 @@
                           getAll ();
               }
           } catch (NullPointerException ne) {
  -            //no members
  +            logger.debug ("No members");
           }
  -        
  +
   //        // test if the properties file contains the 
SEARCH_USER_ATTRIBUTE_NAME value
   //        if (ldapProperties.getProperty(SEARCH_USER_ATTRIBUTE_NAME) == 
null) {
   //           logger.error("Missing the attribute type stored in the " + 
GROUP_MEMBERS_ATTRIBUTE + " group attribute.");
   //           return members;
   //        }
  -        
  +
           // EP : 2004-21-07 : refactoring : uses old way if 
SEARCH_USER_ATTRIBUTE_NAME not defined
           String searchProperties = ldapProperties.getProperty 
(SEARCH_USER_ATTRIBUTE_NAME);
           boolean searchUserDefined = (!(searchProperties == null) && 
(searchProperties.length() > 0));
  @@ -1321,7 +1372,6 @@
           if (answer != null) {
               while (answer.hasMore ()) {
                   String userKey = (String)answer.next ();
  -                logger.debug ("Member value : "+userKey);
                   if (dynamic) {
                       Properties p = new Properties();
                       p.put("ldap.url", userKey);
  @@ -1353,13 +1403,15 @@
   
   
       public synchronized JahiaUserManagerLDAPProvider 
getUserManagerProvider() {
  -        Vector v = 
ServicesRegistry.getInstance().getJahiaUserManagerService().getProviderList();
  -        for (Iterator iterator = v.iterator(); iterator.hasNext();) {
  -            JahiaUserManagerProvider userManagerProviderBean = 
(JahiaUserManagerProvider) iterator.next();
  -            if 
(userManagerProviderBean.getClass().getName().equals(JahiaUserManagerLDAPProvider.class.getName()))
 {
  -                JahiaUserManagerLDAPProvider jahiaUserManagerLDAPProvider = 
(JahiaUserManagerLDAPProvider)userManagerProviderBean;
  -                if 
(jahiaUserManagerLDAPProvider.getUrl().equals(ldapProperties.get(LDAP_URL_PROP)))
 {
  -                    userProvider = jahiaUserManagerLDAPProvider;
  +        if (userProvider == null) {
  +            Vector v = 
ServicesRegistry.getInstance().getJahiaUserManagerService().getProviderList();
  +            for (Iterator iterator = v.iterator(); iterator.hasNext();) {
  +                JahiaUserManagerProvider userManagerProviderBean = 
(JahiaUserManagerProvider) iterator.next();
  +                if 
(userManagerProviderBean.getClass().getName().equals(JahiaUserManagerLDAPProvider.class.getName()))
 {
  +                    JahiaUserManagerLDAPProvider 
jahiaUserManagerLDAPProvider = 
(JahiaUserManagerLDAPProvider)userManagerProviderBean;
  +                    if 
(jahiaUserManagerLDAPProvider.getUrl().equals(ldapProperties.get(LDAP_URL_PROP)))
 {
  +                        userProvider = jahiaUserManagerLDAPProvider;
  +                    }
                   }
               }
           }
  
  
  
  Index: JahiaLDAPGroup.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPGroup.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JahiaLDAPGroup.java       6 Oct 2005 15:56:07 -0000       1.7
  +++ JahiaLDAPGroup.java       14 Dec 2005 17:18:06 -0000      1.8
  @@ -6,10 +6,7 @@
   import org.jahia.registries.ServicesRegistry;
   
   import java.security.Principal;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Iterator;
  -import java.util.Properties;
  +import java.util.*;
   
   
   /**
  @@ -44,6 +41,12 @@
       // LDAP dynamic group (groupOfURLs)
       private boolean dynamic;
   
  +    private boolean preloadedGroups;
  +
  +    private JahiaGroupManagerLDAPProvider myProvider;
  +
  +    private Set notMembers = new HashSet();
  +
       /**
        * Instanciate a new JahiaDBGroup object.
        *
  @@ -54,7 +57,7 @@
        * @param dynamic
        */
       protected JahiaLDAPGroup (int id, String groupname, String groupKey, int 
siteID,
  -                              Hashtable members, Properties properties, 
boolean dynamic)
  +                              Hashtable members, Properties properties, 
boolean dynamic, boolean preloadedGroups, JahiaGroupManagerLDAPProvider 
provider)
               throws JahiaException {
           ServicesRegistry registry = ServicesRegistry.getInstance ();
           if (registry == null) {
  @@ -76,6 +79,8 @@
               mProperties = properties;
           }
           this.dynamic = dynamic;
  +        this.preloadedGroups = preloadedGroups;
  +        this.myProvider = provider;        
       }
   
   
  @@ -219,7 +224,7 @@
   
       public boolean equals (Object another) {
           if (this == another) return true;
  -        
  +
           if (another != null && this.getClass() == another.getClass()) {
               return (getName().equals(((JahiaGroup) another).getName()));
           }
  @@ -236,5 +241,21 @@
           mSiteID = id;
       }
   
  -
  +   public boolean isMember(Principal principal) {
  +        if (super.isMember(principal)) {
  +            return true;
  +        }
  +        if (!preloadedGroups && principal instanceof JahiaUser) {
  +            if (notMembers.contains(principal.getName())) {
  +                return false;
  +            }
  +            if 
(myProvider.getUserMembership((JahiaUser)principal).contains(getGroupKey())) {
  +                mMembers.put(principal.getName(), principal);
  +                return true;
  +            } else {
  +                notMembers.add(principal.getName());
  +            }
  +        }
  +        return false;
  +    }
   }
  
  
  
  Index: JahiaLDAPUser.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/usermanager/JahiaLDAPUser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JahiaLDAPUser.java        6 Oct 2005 15:56:07 -0000       1.10
  +++ JahiaLDAPUser.java        14 Dec 2005 17:18:07 -0000      1.11
  @@ -54,6 +54,9 @@
       /** DN in ldap repository **/
       private String mDn;
   
  +    /** groups **/
  +    private Vector mGroups;
  +
       /** User additional parameters. */
       private UserProperties mProperties = new UserProperties ();
   
  @@ -343,6 +346,14 @@
           return setProperty (mHOMEPAGE_PROP, String.valueOf (id));
       }
   
  +    public Vector getGroups() {
  +        return mGroups;
  +    }
  +
  +    public void setGroups(Vector mGroups) {
  +        this.mGroups = mGroups;
  +    }
  +
       public boolean verifyPassword (String password) {
   
           if (password != null) {
  
  
  
  Index: JahiaUserManagerLDAPProvider.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/usermanager/JahiaUserManagerLDAPProvider.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JahiaUserManagerLDAPProvider.java 6 Oct 2005 15:56:07 -0000       1.17
  +++ JahiaUserManagerLDAPProvider.java 14 Dec 2005 17:18:07 -0000      1.18
  @@ -508,7 +508,7 @@
                       DEFAULT_CONFIGURATION_FILE +
                       ", limiting to " +
                       this.ldapProperties.getProperty 
(SEARCH_COUNT_LIMIT_PROP) +
  -                    " first results...", slee);
  +                    " first results...");
           } catch (NamingException ne) {
               logger.warn ("JNDI warning",ne);
               invalidatePublicCtx ();
  @@ -559,7 +559,7 @@
                   DEFAULT_CONFIGURATION_FILE +
                   ", limiting to " +
                   this.ldapProperties.getProperty(SEARCH_COUNT_LIMIT_PROP) +
  -                " first results...", slee);
  +                " first results...");
           } catch (NamingException ne) {
               logger.warn ("JNDI warning",ne);
               invalidatePublicCtx ();
  @@ -625,7 +625,7 @@
                   DEFAULT_CONFIGURATION_FILE +
                   ", limiting to " +
                   this.ldapProperties.getProperty(SEARCH_COUNT_LIMIT_PROP) +
  -                " first results...", slee);
  +                " first results...");
           } catch (NamingException ne) {
               logger.warn ("JNDI warning",ne);
               invalidatePublicCtx ();
  @@ -871,7 +871,9 @@
       public JahiaLDAPUser lookupUserFromDN(String dn) {
           logger.debug ("Lookup user from dn " + dn);
           JahiaLDAPUser user = null;
  -
  +        if (mUserCache.containsKey("d"+dn)) {
  +            return (JahiaLDAPUser) mUserCache.get("d"+dn);
  +        }
           try {
               String baseName = dn.substring(dn.indexOf(',')+1);
               // might check if base name match the search base defined in 
properties
  @@ -901,7 +903,7 @@
                   return null;
               }
               user = ldapToJahiaUser (sr);
  -
  +            mUserCache.put("d"+dn, user);
           } catch (SizeLimitExceededException slee) {
               logger.debug(
                   "Search generated more than configured maximum search limit 
in " +
  @@ -1421,6 +1423,9 @@
               } else {
                   intScope = SearchControls.SUBTREE_SCOPE;
               }
  +            if (filters.containsKey("user.key")) {
  +                thisFilter = "(&("+ldapProperties.getProperty 
(UID_SEARCH_ATTRIBUTE_PROP)+"="+filters.get("user.key")+")("+thisFilter+"))";
  +            }
   
               return getUsers(ctx, thisFilter, thisBase, intScope);
           } else {
  @@ -1504,6 +1509,9 @@
                       searchBase,
                       filterString.toString (),
                       searchCtl);
  +        } catch (javax.naming.NoInitialContextException nice) {
  +            logger.warn("Reconnection required", nice);
  +            return getUsers(getPublicContext(true), filterString, 
searchBase, scope);
           } catch (javax.naming.CannotProceedException cpe) {
               logger.warn("Reconnection required", cpe);
               return getUsers(getPublicContext(true), filterString, 
searchBase, scope);
  
  
  
  Index: groups.ldap.properties
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/ldap/groups.ldap.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- groups.ldap.properties    28 Jul 2004 11:54:49 -0000      1.3
  +++ groups.ldap.properties    14 Dec 2005 17:18:07 -0000      1.4
  @@ -1,24 +1,30 @@
   # Configuration file for standard ldap server
   groups.ldap.context.factory               = com.sun.jndi.ldap.LdapCtxFactory
  -groups.ldap.url                           = ldap://192.168.2.3:389/
  +groups.ldap.url                           = ldap://127.0.0.1:389/
   groups.ldap.authentification.mode         = simple
   groups.ldap.public.bind.dn                =
   
   # if you need to login to do public browsing of the directory, uncomment the 
following line and enter the password.
  -groups.ldap.public.bind.password          = secret
  +groups.ldap.public.bind.password          =
   
   # attribute holding the group name
   groups.ldap.search.attribute              = cn
   # base dn search
   groups.ldap.search.name                        = dc=jahia
   groups.ldap.search.countlimit                  = 100
  +
  +# objectclasses and member attributes
   groups.ldap.search.objectclass            = groupOfUniqueNames
  +groups.ldap.members.attribute                  = uniqueMember
  +groups.ldap.dynamic.search.objectclass    = groupOfURLs
  +groups.ldap.dynamic.members.attribute          = memberurl
  +
  +# if set to false, group members will not be preloaded and members will not 
appear in engines
  +groups.ldap.preload                       = false
   
   # the following defines the attributes to use for wildcard search such as 
*=*test*
   groups.ldap.search.wildcards.attributes   = cn,description,uniqueMember
   
  -# attribute containing members of a group
  -groups.ldap.members.attribute                  = uniqueMember
   
   # Map attribute, that indicate which LDAP attribute to map to Jahia standard 
properties
   # Make sure you comment out the ones you are not using, especially if the 
LDAP
  
  
  
  Index: users.ldap.properties
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/ldap/users.ldap.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- users.ldap.properties     3 Mar 2005 14:27:19 -0000       1.4
  +++ users.ldap.properties     14 Dec 2005 17:18:07 -0000      1.5
  @@ -1,11 +1,11 @@
   # Configuration file for standard ldap server
   users.ldap.context.factory                = com.sun.jndi.ldap.LdapCtxFactory
  -users.ldap.url                            = ldap://localhost:389/
  +users.ldap.url                            = ldap://127.0.0.1:389/
   users.ldap.authentification.mode          = simple
   users.ldap.public.bind.dn                 =
   
   # if you need to login to do public browsing of the directory, uncomment the 
following line and enter the password.
  -#users.ldap.public.bind.password           = password
  +users.ldap.public.bind.password           =
   
   # the following value will be used as the user key, if it's not found the 
user will not be used !
   users.ldap.uid.search.attribute           = cn
  @@ -21,7 +21,7 @@
   # Make sure you comment out the ones you are not using, especially if the 
LDAP
   # repository contains same names attributes. If you don't searching users 
will
   # most probably not work correctly.
  -users.ldap.username.attribute.map         = cn
  +users.ldap.defined.username.attribute.map = cn
   users.ldap.firstname.attribute.map        = givenName
   users.ldap.lastname.attribute.map         = sn
   users.ldap.email.attribute.map            = mail
  

Reply via email to