public function testLoginNameExists() { $outcome = DB::loginNameExists(self::$userX['LoginName']); $this->assertTrue($outcome); $outcome = DB::loginNameExists(self::$userZ['LoginName']); $this->assertFalse($outcome); }
//distinguish between internal (those in the LDAP) and external Shibboleth users $adapter = new \OCA\user_shibboleth\LdapBackendAdapter(); $loginName = $adapter->getUuid($mail); if ($loginName) { //user is internal, backends are enabled, and user mapping is active $adapter->initializeUser($loginName); } else { //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