//user is external //crop $mail to fit into display_name column of oc_shibboleth_user if (strlen($mail) > 64) { $mail = substr($mail, 0, 64); } //make sure that user entry exists in oc_shibboleth_user $loginName = \OCA\user_shibboleth\LoginLib::persistentId2LoginName($persistentId); $displayName = $mail; if (\OCA\user_shibboleth\DB::loginNameExists($loginName)) { //update display name if it has changed since last login if ($displayName !== \OCA\user_shibboleth\DB::getDisplayName($loginName)) { \OCA\user_shibboleth\DB::updateDisplayName($loginName, $displayName); } } else { //create a new user account $homeDir = \OCA\user_shibboleth\LoginLib::getHomeDirPath($loginName); \OCA\user_shibboleth\DB::addUser($loginName, $displayName, $homeDir); } } //perform OC login \OC_User::login($loginName, 'irrelevant'); \OCP\Util::writeLog('user_shibboleth', 'Login ' . $loginName, \OCP\Util::DEBUG); } else { //not authenticated, yet //follow shibboleth authentication procedure $location = $sessionsHandlerUrl . $sessionInitiatorLocation . '?target=' . \OCA\user_shibboleth\LoginLib::getForwardingPageUrl(); } } else { \OCP\Util::writeLog('user_shibboleth', 'backend not enabled or not configured', \OCP\Util::INFO); } header('Location: ' . $location);
public function testGetDisplayNames() { $result = DB::getDisplayNames('mister', 10, 0); $this->assertEquals($result[self::$userX['LoginName']], self::$userX['DisplayName']); $this->assertEquals($result[self::$userY['LoginName']], self::$userY['DisplayName']); }