r2803 - pull bugfix from maintenance into trunk
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 26 May 2009 10:31:13 +0000 (10:31 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 26 May 2009 10:31:13 +0000 (10:31 +0000)
ChangeLog
inc/auth.php

index 15711328bbb1a2e3e6cbdf673536a7bf0b089e4f..2d58ef665e1486522ef9fee81f02c6a681cf98e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 0.17.1
        bugfix: tags were not displayed on "File" page
        bugfix: multiline comment for an added file was stored incorrectly
+       bugfix: user's displayed name was sometimes lost with LDAP auth
 0.17.0 2009-05-20
        new feature: file attachments (by Aaron)
        new feature: ability to delete objects (by Aaron)
index 87cfb57644738088cc9d1bce4e1e2dd3d6cb3f09..faa3dcda1568d4b85e448020f7a7127368151c80 100644 (file)
@@ -163,13 +163,14 @@ function authenticated_via_ldap ($username, $password)
                $newinfo = queryLDAPServer ($username, $password);
                if ($newinfo['result'] == 'ACK')
                {
-                       $remote_displayname = $newinfo['displayed_name'];
+                       if (strlen ($newinfo['displayed_name']))
+                               $remote_displayname = $newinfo['displayed_name'];
                        foreach ($newinfo['memberof'] as $autotag)
                                $auto_tags[] = array ('tag' => $autotag);
                        replaceLDAPCacheRecord ($username, sha1 ($password), $newinfo['displayed_name'], $newinfo['memberof']);
                }
                releaseLDAPCache();
-               // Do cache maintenence each time fresh data is stored.
+               // Do cache maintenance each time fresh data is stored.
                discardLDAPCache ($LDAP_options['cache_expiry']);
                return $newinfo['result'] == 'ACK';
        }
@@ -179,7 +180,8 @@ function authenticated_via_ldap ($username, $password)
        if ($oldinfo['success_age'] < $LDAP_options['cache_refresh'] or $oldinfo['retry_age'] < $LDAP_options['cache_retry'])
        {
                releaseLDAPCache();
-               $remote_displayname = $oldinfo['displayed_name'];
+               if (strlen ($oldinfo['displayed_name']))
+                       $remote_displayname = $oldinfo['displayed_name'];
                foreach ($oldinfo['memberof'] as $autotag)
                        $auto_tags[] = array ('tag' => $autotag);
                return TRUE;
@@ -189,7 +191,8 @@ function authenticated_via_ldap ($username, $password)
        switch ($newinfo['result'])
        {
        case 'ACK': // refresh existing record
-               $remote_displayname = $newinfo['displayed_name'];
+               if (strlen ($newinfo['displayed_name']))
+                       $remote_displayname = $newinfo['displayed_name'];
                foreach ($newinfo['memberof'] as $autotag)
                        $auto_tags[] = array ('tag' => $autotag);
                replaceLDAPCacheRecord ($username, sha1 ($password), $newinfo['displayed_name'], $newinfo['memberof']);
@@ -200,7 +203,8 @@ function authenticated_via_ldap ($username, $password)
                releaseLDAPCache();
                return FALSE;
        case 'CAN': // retry failed, do nothing, use old value till next retry
-               $remote_displayname = $oldinfo['displayed_name'];
+               if (strlen ($oldinfo['displayed_name']))
+                       $remote_displayname = $oldinfo['displayed_name'];
                foreach ($oldinfo['memberof'] as $autotag)
                        $auto_tags[] = array ('tag' => $autotag);
                touchLDAPCacheRecord ($username);
@@ -275,11 +279,8 @@ function queryLDAPServer ($username, $password)
        // Displayed name only makes sense for authenticated users anyway.
        if
        (
-               isset ($LDAP_options['displayname_attrs']) and
-               count ($LDAP_options['displayname_attrs']) and
-               isset ($LDAP_options['search_dn']) and
+               !empty ($LDAP_options['displayname_attrs']) and
                !empty ($LDAP_options['search_dn']) and
-               isset ($LDAP_options['search_attr']) and
                !empty ($LDAP_options['search_attr'])
        )
        {