diff --git a/module/VuFind/src/VuFind/Auth/LDAP.php b/module/VuFind/src/VuFind/Auth/LDAP.php index 4730d240d4f92eb5e8c5c982fbad9cfcabdb9f48..482c91ab902805432567df6d22688385148604ac 100644 --- a/module/VuFind/src/VuFind/Auth/LDAP.php +++ b/module/VuFind/src/VuFind/Auth/LDAP.php @@ -207,6 +207,10 @@ class LDAP extends AbstractBase // User object to populate from LDAP: $user = $this->getUserTable()->getByUsername($this->username); + // Variable to hold catalog password (handled separately from other + // attributes since we need to use saveCredentials method to store it): + $catPassword = null; + // Loop through LDAP response and map fields to database object based // on configuration settings: for ($i = 0; $i < $data["count"]; $i++) { @@ -214,12 +218,21 @@ class LDAP extends AbstractBase foreach ($fields as $field) { $configValue = $this->getSetting($field); if ($data[$i][$j] == $configValue && !empty($configValue)) { - $user->$field = $data[$i][$data[$i][$j]][0]; + if ($field != "cat_password" ) { + $user->$field = $data[$i][$data[$i][$j]][0]; + } else { + $catPassword = $data[$i][$data[$i][$j]][0]; + } } } } } + // Save credentials if applicable: + if (!empty($catPassword) && !empty($user->cat_username)) { + $user->saveCredentials($user->cat_username, $catPassword); + } + // Update the user in the database, then return it to the caller: $user->save(); return $user;