public static function ldapAuthenticate(User $user, $password, PropelPDO $con = null) { $account = $user->getAccount($con); if ($account === null) { throw new Exception('Could not determine account of user #' . $user->getId() . ' "' . $user->getName . '".'); } $ldapSettings = PropertyPeer::getAll($account, null, null, array(self::LDAP_SETTING_HOST, self::LDAP_SETTING_LOGIN_NAME, self::LDAP_SETTING_OPTIONS, self::LDAP_SETTING_PORT), $con); if (!isset($ldapSettings[self::LDAP_SETTING_HOST], $ldapSettings[self::LDAP_SETTING_LOGIN_NAME])) { return false; } $ldapLoginName = KeyReplace::replace($ldapSettings[self::LDAP_SETTING_LOGIN_NAME], array('user' => $user->getName(), 'account' => $account->getIdentifier())); if ((string) $password === '') { return false; } //throw new Exception('Password must not be empty for LDAP authentication.'); try { new LDAP($ldapSettings[self::LDAP_SETTING_HOST], $ldapLoginName, $password, (isset($ldapSettings[self::LDAP_SETTING_OPTIONS]) and is_array($ldapSettings[self::LDAP_SETTING_OPTIONS])) ? $ldapSettings[self::LDAP_SETTING_OPTIONS] : array(), isset($ldapSettings[self::LDAP_SETTING_PORT]) ? $ldapSettings[self::LDAP_SETTING_PORT] : null); return true; } catch (Exception $e) { return false; } }
protected function _ENV($elem) { $key = (string) $elem['KEY']; switch ($elem['TYPE']) { case 'tymio': switch ($key) { case 'API_URL': return $this->getApiUrl(); default: return null; } case 'server': return isset($_SERVER[$key]) ? $_SERVER[$key] : null; case 'property': default: $userId = (string) $elem['USER']; $user = $this->getUser($this->user, $userId); return $key === '' ? PropertyPeer::getAll($this->account, null, $user) : PropertyPeer::get($key, $this->account, null, $user); } }