/** * Check Credentials, ldap password != contao password * @param String - Input Username $username * @param String - Input Password $password * @param unknown $objMember */ public function checkCredentialsHook($strUsername, $strPassword, $objMember) { // store randomized password, so contao will always trigger the checkCredentials HOOK $objMember1 = \MemberModel::findByPk($objMember->id); LdapMember::resetPassword($objMember1, $strUsername); if (LdapMember::authenticateLdapMember($strUsername, $strPassword)) { LdapMember::doUpdateMember($objMember1, $objMember1->ldapUid, $objMember1->email, $objMember1->firstname, $objMember1->lastname, deserialize($GLOBALS['TL_CONFIG']['ldap_groups'], true)); return true; } else { return false; } }
/** * Store Login Module ID in Session, required by LdapAuth (Module config) * @return string */ public function generate() { // Login if (\Input::post('FORM_SUBMIT') == 'tl_login') { if (\Input::post('username', true) && \Input::post('password', true)) { $objMember = \MemberModel::findBy('username', \Input::post('username', true)); if ($objMember !== null) { // always reset the password to a random value, otherwise checkCredentialsHook will never be triggered LdapMember::resetPassword($objMember, \Input::post('username', true)); } } // validate email if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) { \Message::addError($GLOBALS['TL_LANG']['ERR']['email']); $this->reload(); } } $strParent = parent::generate(); return $strParent; }