Exemplo n.º 1
0
 /**
  * assigns the instances passed to run() to the class properties
  * @param array $arguments
  */
 public function setArguments($arguments)
 {
     //Dependency Injection is not possible, because the constructor will
     //only get values that are serialized to JSON. I.e. whatever we would
     //pass in app.php we do add here, except something else is passed e.g.
     //in tests.
     if (isset($arguments['helper'])) {
         $this->ldapHelper = $arguments['helper'];
     } else {
         $this->ldapHelper = new Helper();
     }
     if (isset($arguments['userBackend'])) {
         $this->userBackend = $arguments['userBackend'];
     } else {
         $this->userBackend = new User_Proxy($this->ldapHelper->getServerConfigurationPrefixes(true), new LDAP());
     }
     if (isset($arguments['ocConfig'])) {
         $this->ocConfig = $arguments['ocConfig'];
     } else {
         $this->ocConfig = \OC::$server->getConfig();
     }
     if (isset($arguments['db'])) {
         $this->db = $arguments['db'];
     } else {
         $this->db = \OC::$server->getDatabaseConnection();
     }
 }
Exemplo n.º 2
0
 protected function getNewConfigurationPrefix()
 {
     $serverConnections = $this->helper->getServerConfigurationPrefixes();
     // first connection uses no prefix
     if (sizeof($serverConnections) == 0) {
         return '';
     }
     sort($serverConnections);
     $lastKey = array_pop($serverConnections);
     $lastNumber = intval(str_replace('s', '', $lastKey));
     $nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
     return $nextPrefix;
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $availableConfigs = $this->helper->getServerConfigurationPrefixes();
     $configID = $input->getArgument('configID');
     if (!is_null($configID)) {
         $configIDs[] = $configID;
         if (!in_array($configIDs[0], $availableConfigs)) {
             $output->writeln("Invalid configID");
             return;
         }
     } else {
         $configIDs = $availableConfigs;
     }
     $this->renderConfigs($configIDs, $output, $input->getOption('show-password'));
 }
Exemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $availableConfigs = Helper::getServerConfigurationPrefixes();
     $configID = $input->getArgument('configID');
     if (!in_array($configID, $availableConfigs)) {
         $output->writeln("Invalid configID");
         return;
     }
     $this->setValue($configID, $input->getArgument('configKey'), $input->getArgument('configValue'));
 }
Exemplo n.º 5
0
 /**
  * Constructor
  * @param ILDAPWrapper $ldap
  * @param string $configPrefix a string with the prefix for the configkey column (appconfig table)
  * @param string|null $configID a string with the value for the appid column (appconfig table) or null for on-the-fly connections
  */
 public function __construct(ILDAPWrapper $ldap, $configPrefix = '', $configID = 'user_ldap')
 {
     parent::__construct($ldap);
     $this->configPrefix = $configPrefix;
     $this->configID = $configID;
     $this->configuration = new Configuration($configPrefix, !is_null($configID));
     $memcache = \OC::$server->getMemCacheFactory();
     if ($memcache->isAvailable()) {
         $this->cache = $memcache->create();
     }
     $this->hasPagedResultSupport = $this->ldap->hasPagedResultSupport();
     $helper = new Helper();
     $this->doNotValidate = !in_array($this->configPrefix, $helper->getServerConfigurationPrefixes());
 }
Exemplo n.º 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configPrefixes = Helper::getServerConfigurationPrefixes(true);
     $ldapWrapper = new LDAP();
     $offset = intval($input->getOption('offset'));
     $limit = intval($input->getOption('limit'));
     $this->validateOffsetAndLimit($offset, $limit);
     if ($input->getOption('group')) {
         $proxy = new Group_Proxy($configPrefixes, $ldapWrapper);
         $getMethod = 'getGroups';
         $printID = false;
     } else {
         $proxy = new User_Proxy($configPrefixes, $ldapWrapper);
         $getMethod = 'getDisplayNames';
         $printID = true;
     }
     $result = $proxy->{$getMethod}($input->getArgument('search'), $limit, $offset);
     foreach ($result as $id => $name) {
         $line = $name . ($printID ? ' (' . $id . ')' : '');
         $output->writeln($line);
     }
 }
Exemplo n.º 7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $availableConfigs = Helper::getServerConfigurationPrefixes();
     $configID = $input->getArgument('configID');
     if (!in_array($configID, $availableConfigs)) {
         $output->writeln("Invalid configID");
         return;
     }
     $result = $this->testConfig($configID);
     if ($result === 0) {
         $output->writeln('The configuration is valid and the connection could be established!');
     } else {
         if ($result === 1) {
             $output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
         } else {
             if ($result === 2) {
                 $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
             } else {
                 $output->writeln('Your LDAP server was kidnapped by aliens.');
             }
         }
     }
 }
<?php

/**
 * Copyright (c) 2014 Arthur Schiwon <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
use OCA\user_ldap\lib\Helper;
use OCA\user_ldap\lib\LDAP;
use OCA\user_ldap\User_Proxy;
$application->add(new OCA\user_ldap\Command\ShowConfig());
$application->add(new OCA\user_ldap\Command\SetConfig());
$application->add(new OCA\user_ldap\Command\TestConfig());
$application->add(new OCA\user_ldap\Command\Search());
$application->add(new OCA\user_ldap\Command\ShowRemnants());
$helper = new OCA\user_ldap\lib\Helper();
$uBackend = new OCA\user_ldap\User_Proxy($helper->getServerConfigurationPrefixes(true), new OCA\user_ldap\lib\LDAP());
$application->add(new OCA\user_ldap\Command\CheckUser($uBackend, $helper, \OC::$server->getConfig()));
Exemplo n.º 9
0
Arquivo: jobs.php Projeto: evanjt/core
 /**
  * @return \OCA\user_ldap\GROUP_LDAP|\OCA\user_ldap\Group_Proxy
  */
 private static function getGroupBE()
 {
     if (!is_null(self::$groupBE)) {
         return self::$groupBE;
     }
     $helper = new Helper();
     $configPrefixes = $helper->getServerConfigurationPrefixes(true);
     $ldapWrapper = new LDAP();
     if (count($configPrefixes) === 1) {
         //avoid the proxy when there is only one LDAP server configured
         $dbc = \OC::$server->getDatabaseConnection();
         $userManager = new user\Manager(\OC::$server->getConfig(), new FilesystemHelper(), new LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), $dbc);
         $connector = new Connection($ldapWrapper, $configPrefixes[0]);
         $ldapAccess = new Access($connector, $ldapWrapper, $userManager);
         $groupMapper = new GroupMapping($dbc);
         $userMapper = new UserMapping($dbc);
         $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);
     }
     return self::$groupBE;
 }
Exemplo n.º 10
0
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
OC_Util::checkAdminUser();
OCP\Util::addScript('user_ldap', 'ldapFilter');
OCP\Util::addScript('user_ldap', 'experiencedAdmin');
OCP\Util::addScript('user_ldap', 'settings');
OCP\Util::addScript('core', 'jquery.multiselect');
OCP\Util::addStyle('user_ldap', 'settings');
OCP\Util::addStyle('core', 'jquery.multiselect');
OCP\Util::addStyle('core', 'jquery-ui-1.10.0.custom');
// fill template
$tmpl = new OCP\Template('user_ldap', 'settings');
$prefixes = \OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes();
$hosts = \OCA\user_ldap\lib\Helper::getServerConfigurationHosts();
$wizardHtml = '';
$toc = array();
$wControls = new OCP\Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
$sControls = new OCP\Template('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
$l = \OC_L10N::get('user_ldap');
$wizTabs = array();
$wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server'));
$wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('User Filter'));
$wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Filter'));
$wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Group Filter'));
for ($i = 0; $i < count($wizTabs); $i++) {
    $tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']);
Exemplo n.º 11
0
 /**
  * listens to a hook thrown by server2server sharing and replaces the given
  * login name by a username, if it matches an LDAP user.
  *
  * @param array $param
  * @throws \Exception
  */
 public static function loginName2UserName($param)
 {
     if (!isset($param['uid'])) {
         throw new \Exception('key uid is expected to be set in $param');
     }
     //ain't it ironic?
     $helper = new Helper();
     $configPrefixes = $helper->getServerConfigurationPrefixes(true);
     $ldapWrapper = new LDAP();
     $ocConfig = \OC::$server->getConfig();
     $userBackend = new User_Proxy($configPrefixes, $ldapWrapper, $ocConfig);
     $uid = $userBackend->loginName2UserName($param['uid']);
     if ($uid !== false) {
         $param['uid'] = $uid;
     }
 }
Exemplo n.º 12
0
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
use OCA\user_ldap\lib\Helper;
use OCA\user_ldap\lib\LDAP;
use OCA\user_ldap\User_Proxy;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\lib\User\DeletedUsersIndex;
$dbConnection = \OC::$server->getDatabaseConnection();
$userMapping = new UserMapping($dbConnection);
$helper = new Helper();
$ocConfig = \OC::$server->getConfig();
$uBackend = new User_Proxy($helper->getServerConfigurationPrefixes(true), new LDAP(), $ocConfig);
$deletedUsersIndex = new DeletedUsersIndex($ocConfig, $dbConnection, $userMapping);
$application->add(new OCA\user_ldap\Command\ShowConfig($helper));
$application->add(new OCA\user_ldap\Command\SetConfig());
$application->add(new OCA\user_ldap\Command\TestConfig());
$application->add(new OCA\user_ldap\Command\CreateEmptyConfig($helper));
$application->add(new OCA\user_ldap\Command\DeleteConfig($helper));
$application->add(new OCA\user_ldap\Command\Search($ocConfig));
$application->add(new OCA\user_ldap\Command\ShowRemnants($deletedUsersIndex, \OC::$server->getDateTimeFormatter()));
$application->add(new OCA\user_ldap\Command\CheckUser($uBackend, $helper, $deletedUsersIndex, $userMapping));