[dev] Fwd: Patch for Horde / IMP bug that causes all prefs to be erased

Chuck Hagenbuch chuck at horde.org
Mon Nov 3 08:29:04 PST 2003



----- Forwarded message from lee at disinfo.com -----
    Date: Mon, 3 Nov 2003 10:48:20 -0500
    From: Lee <lee at disinfo.com>
Reply-To: Lee <lee at disinfo.com>
 Subject: Patch for Horde / IMP bug that causes all prefs to be erased
      To: Chuck Hagenbuch <chuck at horde.org>

Chuck,
I submitted a bug report quite a while ago, reporting that in the
latest stable releases of horde/turba (using an ldap prefs backend) if
a user logged in while the ldap server was down, and during the user's
session the ldap server came back online, then all of the user's prefs
including identities and filters would be overwritten in the ldap
directory with default blank values. This was obviously a serious
concern to us as many users have many identities and filters setup in
their account.

Well it took me some time to find a solution that finally worked, but i
have one. The two changes below simply log the user out if the ldap
server with their prefs is down. While I originally thought users
should still be able to log in even if their identities, filters and
prefs were not available, after seeing our support requests when this
happens, Ive realized that its best not to have this happen as users
tend to immediately try to "redo" or make changes to the empty default
prefs, only to find that these changes all disappear next time they
login (assuming the ldap server doesnt come back up during their
session, in which case their old prefs are destroyed).

Anyway the changes below are against the latest stable releases, but
they should be quite simple to apply to head.

------------------------------------------------------

in lib/Prefs/ldap.php around line 121:

             Horde::logMessage(
                 sprintf('Failed to open an LDAP connection to %s.',
                         $this->params['hostspec']),
                 __FILE__, __LINE__);
             /* New Code To Add */
+         $url = Horde::applicationUrl(IMP::logoutUrl('login.php',
"logout"), true);
+         $url = IMP::addParameter($url, 'url=' .
urlencode(Horde::selfUrl()));
+         header('Location: ' . $url);
             /* End New Code To Add*/

in lib/Prefs/ldap.php around line 180:

             Horde::logMessage(
                 sprintf('Bind to server %s:%d with DN %s failed: [%d]
%s',
                         $this->params['hostspec'],
                         $this->params['port'],
                         $bind_dn,
                         ldap_errno($this->connection),
                         ldap_error($this->connection)),
                 __FILE__, __LINE__);
             /* New Code To Add */
+          $url = Horde::applicationUrl(IMP::logoutUrl('login.php',
"logout"), true);
+          $url = IMP::addParameter($url, 'url=' .
urlencode(Horde::selfUrl()));
+          header('Location: ' . $url);
             /* End New Code To Add */

------------------------------------------------------

Best,
Lee Hoffman



----- End forwarded message -----


-chuck

--
Charles Hagenbuch, <chuck at horde.org>
Born right the first time.


More information about the dev mailing list