new LDAP()
);
$deletedUsersIndex = new DeletedUsersIndex(
- \OC::$server->getConfig(), $dbConnection, $userMapping);
+ \OC::$server->getConfig(), $dbConnection, $userMapping
+);
$application->add(new OCA\user_ldap\Command\ShowConfig());
$application->add(new OCA\user_ldap\Command\SetConfig());
$application->add(new OCA\user_ldap\Command\CreateEmptyConfig());
$application->add(new OCA\user_ldap\Command\DeleteConfig());
$application->add(new OCA\user_ldap\Command\Search());
-$application->add(new OCA\user_ldap\Command\ShowRemnants($userMapping));
+$application->add(new OCA\user_ldap\Command\ShowRemnants($deletedUsersIndex));
$application->add(new OCA\user_ldap\Command\CheckUser(
- $uBackend, $helper, $deletedUsersIndex, $userMapping));
+ $uBackend, $helper, $deletedUsersIndex, $userMapping)
+);
use OCA\user_ldap\lib\user\User;
use OCA\User_LDAP\lib\user\Manager;
use OCA\User_LDAP\lib\User\DeletedUsersIndex;
-use OCA\user_ldap\lib\Helper;
+use OCA\User_LDAP\Mapping\UserMapping;
+use OCA\user_ldap\lib\Helper as LDAPHelper;
use OCA\user_ldap\User_Proxy;
class CheckUser extends Command {
/**
* @param OCA\user_ldap\User_Proxy $uBackend
- * @param OCA\User_LDAP\lib\Helper $helper
- * @param OCP\IConfig $config
+ * @param OCA\user_ldap\lib\Helper $helper
+ * @param OCA\User_LDAP\lib\User\DeletedUsersIndex $dui
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
*/
- public function __construct(User_Proxy $uBackend, Helper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
+ public function __construct(User_Proxy $uBackend, LDAPHelper $helper, DeletedUsersIndex $dui, UserMapping $mapping) {
$this->backend = $uBackend;
$this->helper = $helper;
$this->dui = $dui;
}
/**
- * checks whether the setup allows reliable checking of LDAP user existance
+ * checks whether the setup allows reliable checking of LDAP user existence
* @throws \Exception
- * @return bool
+ * @return true
*/
protected function isAllowed($force) {
if($this->helper->haveDisabledConfigurations() && !$force) {
- throw new \Exception('Cannot check user existance, because '
+ throw new \Exception('Cannot check user existence, because '
. 'disabled LDAP configurations are present.');
}
use OCA\User_LDAP\Mapping\UserMapping;
class ShowRemnants extends Command {
- /** @var OCA\User_LDAP\Mapping\UserMapping */
- protected $mapping;
+ /** @var use OCA\User_LDAP\lib\User\DeletedUsersIndex; */
+ protected $dui;
/**
- * @param OCA\user_ldap\User_Proxy $uBackend
- * @param OCA\User_LDAP\lib\Helper $helper
- * @param OCP\IConfig $config
+ * @param OCA\user_ldap\lib\user\DeletedUsersIndex $dui
*/
- public function __construct(UserMapping $mapper) {
- $this->mapper = $mapper;
+ public function __construct(DeletedUsersIndex $dui) {
+ $this->dui = $dui;
parent::__construct();
}
;
}
+ /**
+ * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted
+ *
+ * {@inheritdoc}
+ */
protected function execute(InputInterface $input, OutputInterface $output) {
- $dui = new DeletedUsersIndex(
- \OC::$server->getConfig(),
- \OC::$server->getDatabaseConnection(),
- $this->mapper
- );
-
/** @var \Symfony\Component\Console\Helper\Table $table */
$table = $this->getHelperSet()->get('table');
$table->setHeaders(array(
'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login',
'Dir', 'Sharer'));
$rows = array();
- $resultSet = $dui->getUsers();
+ $resultSet = $this->dui->getUsers();
foreach($resultSet as $user) {
$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
$lastLogin = ($user->getLastLogin() > 0) ?
namespace OCA\user_ldap\lib;
use OCA\User_LDAP\Mapping\GroupMapping;
+use OCA\User_LDAP\Mapping\UserMapping;
class Jobs extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB;
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager);
$groupMapper = new GroupMapping(\OC::$server->getDatabaseConnection());
+ $userMapper = new UserMapping(\OC::$server->getDatabaseConnection());
+ $ldapAccess->setGroupMapper($groupMapper);
+ $ldapAccess->setUserMapper($userMapper);
self::$groupBE = new \OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
self::$groupBE = new \OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
* @package OCA\user_ldap\lib;
*/
class CleanUp extends \OC\BackgroundJob\TimedJob {
- /**
- * @var int $limit amount of users that should be checked per run
- */
+ /** @var int $limit amount of users that should be checked per run */
protected $limit = 50;
- /**
- * @var \OCP\UserInterface $userBackend
- */
+ /** @var int $defaultIntervalMin default interval in minutes */
+ protected $defaultIntervalMin = 51;
+
+ /** @var \OCP\UserInterface $userBackend */
protected $userBackend;
- /**
- * @var \OCP\IConfig $ocConfig
- */
+ /** @var \OCP\IConfig $ocConfig */
protected $ocConfig;
- /**
- * @var \OCP\IDBConnection $db
- */
+ /** @var \OCP\IDBConnection $db */
protected $db;
- /**
- * @var Helper $ldapHelper
- */
+ /** @var Helper $ldapHelper */
protected $ldapHelper;
/** @var \OCA\User_LDAP\Mapping\UserMapping */
/** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */
protected $dui;
- /**
- * @var int $defaultIntervalMin default interval in minutes
- */
- protected $defaultIntervalMin = 51;
-
public function __construct() {
$minutes = \OC::$server->getConfig()->getSystemValue(
'ldapUserCleanupInterval', strval($this->defaultIntervalMin));
* checks users whether they are still existing
* @param array $users result from getMappedUsers()
*/
- private function checkUsers($users) {
+ private function checkUsers(array $users) {
foreach($users as $user) {
$this->checkUser($user);
}
* checks whether a user is still existing in LDAP
* @param string[] $user
*/
- private function checkUser($user) {
+ private function checkUser(array $user) {
if($this->userBackend->userExistsOnLDAP($user['name'])) {
//still available, all good
/**
* @var array $deletedUsers
*/
- protected $deletedUsers = false;
+ protected $deletedUsers;
+ /**
+ * @param OCP\IConfig $config
+ * @param OCP\IDBConnection $db
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
+ */
public function __construct(\OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->config = $config;
$this->db = $db;
*/
protected $mapping;
+ /**
+ * @param string $ocName
+ * @param OCP\IConfig $config
+ * @param OCP\IDBConnection $db
+ * @param OCA\User_LDAP\Mapping\UserMapping $mapping
+ */
public function __construct($ocName, \OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->ocName = $ocName;
$this->config = $config;
$this->assertSame(true, $result);
}
- /**
- * test whether sql is OK
- */
- public function test_getMappedUsers() {
- $args = $this->getMocks();
-
- $bgJob = new \OCA\User_LDAP\Jobs\CleanUp();
- $bgJob->setArguments($args);
-
- if(version_compare(\PHPUnit_Runner_Version::id(), '3.8', '<')) {
- //otherwise we run into
- //https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
- $this->markTestIncomplete();
- }
-
- $stmt = $this->getMock('\Doctrine\DBAL\Driver\Statement');
-
- $args['db']->expects($this->once())
- ->method('prepare')
- ->will($this->returnValue($stmt));
-
- $bgJob->getMappedUsers(0, $bgJob->getChunkSize());
- }
-
/**
* check whether offset will be reset when it needs to
*/