@@ -36,80 +36,80 @@ |
||
36 | 36 | * @package OCA\Files\BackgroundJob |
37 | 37 | */ |
38 | 38 | class ScanFiles extends \OC\BackgroundJob\TimedJob { |
39 | - /** @var IConfig */ |
|
40 | - private $config; |
|
41 | - /** @var IUserManager */ |
|
42 | - private $userManager; |
|
43 | - /** @var IDBConnection */ |
|
44 | - private $dbConnection; |
|
45 | - /** @var ILogger */ |
|
46 | - private $logger; |
|
47 | - /** Amount of users that should get scanned per execution */ |
|
48 | - const USERS_PER_SESSION = 500; |
|
39 | + /** @var IConfig */ |
|
40 | + private $config; |
|
41 | + /** @var IUserManager */ |
|
42 | + private $userManager; |
|
43 | + /** @var IDBConnection */ |
|
44 | + private $dbConnection; |
|
45 | + /** @var ILogger */ |
|
46 | + private $logger; |
|
47 | + /** Amount of users that should get scanned per execution */ |
|
48 | + const USERS_PER_SESSION = 500; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param IConfig|null $config |
|
52 | - * @param IUserManager|null $userManager |
|
53 | - * @param IDBConnection|null $dbConnection |
|
54 | - * @param ILogger|null $logger |
|
55 | - */ |
|
56 | - public function __construct(IConfig $config = null, |
|
57 | - IUserManager $userManager = null, |
|
58 | - IDBConnection $dbConnection = null, |
|
59 | - ILogger $logger = null) { |
|
60 | - // Run once per 10 minutes |
|
61 | - $this->setInterval(60 * 10); |
|
50 | + /** |
|
51 | + * @param IConfig|null $config |
|
52 | + * @param IUserManager|null $userManager |
|
53 | + * @param IDBConnection|null $dbConnection |
|
54 | + * @param ILogger|null $logger |
|
55 | + */ |
|
56 | + public function __construct(IConfig $config = null, |
|
57 | + IUserManager $userManager = null, |
|
58 | + IDBConnection $dbConnection = null, |
|
59 | + ILogger $logger = null) { |
|
60 | + // Run once per 10 minutes |
|
61 | + $this->setInterval(60 * 10); |
|
62 | 62 | |
63 | - if (is_null($userManager) || is_null($config)) { |
|
64 | - $this->fixDIForJobs(); |
|
65 | - } else { |
|
66 | - $this->config = $config; |
|
67 | - $this->userManager = $userManager; |
|
68 | - $this->logger = $logger; |
|
69 | - } |
|
70 | - } |
|
63 | + if (is_null($userManager) || is_null($config)) { |
|
64 | + $this->fixDIForJobs(); |
|
65 | + } else { |
|
66 | + $this->config = $config; |
|
67 | + $this->userManager = $userManager; |
|
68 | + $this->logger = $logger; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - protected function fixDIForJobs() { |
|
73 | - $this->config = \OC::$server->getConfig(); |
|
74 | - $this->userManager = \OC::$server->getUserManager(); |
|
75 | - $this->logger = \OC::$server->getLogger(); |
|
76 | - } |
|
72 | + protected function fixDIForJobs() { |
|
73 | + $this->config = \OC::$server->getConfig(); |
|
74 | + $this->userManager = \OC::$server->getUserManager(); |
|
75 | + $this->logger = \OC::$server->getLogger(); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IUser $user |
|
80 | - */ |
|
81 | - protected function runScanner(IUser $user) { |
|
82 | - try { |
|
83 | - $scanner = new Scanner( |
|
84 | - $user->getUID(), |
|
85 | - $this->dbConnection, |
|
86 | - $this->logger |
|
87 | - ); |
|
88 | - $scanner->backgroundScan(''); |
|
89 | - } catch (\Exception $e) { |
|
90 | - $this->logger->logException($e, ['app' => 'files']); |
|
91 | - } |
|
92 | - \OC_Util::tearDownFS(); |
|
93 | - } |
|
78 | + /** |
|
79 | + * @param IUser $user |
|
80 | + */ |
|
81 | + protected function runScanner(IUser $user) { |
|
82 | + try { |
|
83 | + $scanner = new Scanner( |
|
84 | + $user->getUID(), |
|
85 | + $this->dbConnection, |
|
86 | + $this->logger |
|
87 | + ); |
|
88 | + $scanner->backgroundScan(''); |
|
89 | + } catch (\Exception $e) { |
|
90 | + $this->logger->logException($e, ['app' => 'files']); |
|
91 | + } |
|
92 | + \OC_Util::tearDownFS(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @param $argument |
|
97 | - * @throws \Exception |
|
98 | - */ |
|
99 | - protected function run($argument) { |
|
100 | - $offset = $this->config->getAppValue('files', 'cronjob_scan_files', 0); |
|
101 | - $users = $this->userManager->search('', self::USERS_PER_SESSION, $offset); |
|
102 | - if (!count($users)) { |
|
103 | - // No users found, reset offset and retry |
|
104 | - $offset = 0; |
|
105 | - $users = $this->userManager->search('', self::USERS_PER_SESSION); |
|
106 | - } |
|
95 | + /** |
|
96 | + * @param $argument |
|
97 | + * @throws \Exception |
|
98 | + */ |
|
99 | + protected function run($argument) { |
|
100 | + $offset = $this->config->getAppValue('files', 'cronjob_scan_files', 0); |
|
101 | + $users = $this->userManager->search('', self::USERS_PER_SESSION, $offset); |
|
102 | + if (!count($users)) { |
|
103 | + // No users found, reset offset and retry |
|
104 | + $offset = 0; |
|
105 | + $users = $this->userManager->search('', self::USERS_PER_SESSION); |
|
106 | + } |
|
107 | 107 | |
108 | - $offset += self::USERS_PER_SESSION; |
|
109 | - $this->config->setAppValue('files', 'cronjob_scan_files', $offset); |
|
108 | + $offset += self::USERS_PER_SESSION; |
|
109 | + $this->config->setAppValue('files', 'cronjob_scan_files', $offset); |
|
110 | 110 | |
111 | - foreach ($users as $user) { |
|
112 | - $this->runScanner($user); |
|
113 | - } |
|
114 | - } |
|
111 | + foreach ($users as $user) { |
|
112 | + $this->runScanner($user); |
|
113 | + } |
|
114 | + } |
|
115 | 115 | } |
@@ -31,56 +31,56 @@ |
||
31 | 31 | |
32 | 32 | class Admin implements ISettings { |
33 | 33 | |
34 | - /** @var IniGetWrapper */ |
|
35 | - private $iniWrapper; |
|
34 | + /** @var IniGetWrapper */ |
|
35 | + private $iniWrapper; |
|
36 | 36 | |
37 | - /** @var IRequest */ |
|
38 | - private $request; |
|
37 | + /** @var IRequest */ |
|
38 | + private $request; |
|
39 | 39 | |
40 | - public function __construct(IniGetWrapper $iniWrapper, IRequest $request) { |
|
41 | - $this->iniWrapper = $iniWrapper; |
|
42 | - $this->request = $request; |
|
43 | - } |
|
40 | + public function __construct(IniGetWrapper $iniWrapper, IRequest $request) { |
|
41 | + $this->iniWrapper = $iniWrapper; |
|
42 | + $this->request = $request; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return TemplateResponse |
|
47 | - */ |
|
48 | - public function getForm() { |
|
49 | - $htaccessWorking = (getenv('htaccessWorking') == 'true'); |
|
50 | - $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess'); |
|
51 | - $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini'); |
|
45 | + /** |
|
46 | + * @return TemplateResponse |
|
47 | + */ |
|
48 | + public function getForm() { |
|
49 | + $htaccessWorking = (getenv('htaccessWorking') == 'true'); |
|
50 | + $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess'); |
|
51 | + $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini'); |
|
52 | 52 | |
53 | - $upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize'); |
|
54 | - $post_max_size = $this->iniWrapper->getBytes('post_max_size'); |
|
55 | - $maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size)); |
|
53 | + $upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize'); |
|
54 | + $post_max_size = $this->iniWrapper->getBytes('post_max_size'); |
|
55 | + $maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size)); |
|
56 | 56 | |
57 | - $parameters = [ |
|
58 | - 'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ), |
|
59 | - 'uploadMaxFilesize' => $maxUploadFilesize, |
|
60 | - // max possible makes only sense on a 32 bit system |
|
61 | - 'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4, |
|
62 | - 'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX), |
|
63 | - ]; |
|
57 | + $parameters = [ |
|
58 | + 'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ), |
|
59 | + 'uploadMaxFilesize' => $maxUploadFilesize, |
|
60 | + // max possible makes only sense on a 32 bit system |
|
61 | + 'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4, |
|
62 | + 'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX), |
|
63 | + ]; |
|
64 | 64 | |
65 | - return new TemplateResponse('files', 'admin', $parameters, ''); |
|
66 | - } |
|
65 | + return new TemplateResponse('files', 'admin', $parameters, ''); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string the section ID, e.g. 'sharing' |
|
70 | - */ |
|
71 | - public function getSection() { |
|
72 | - return 'additional'; |
|
73 | - } |
|
68 | + /** |
|
69 | + * @return string the section ID, e.g. 'sharing' |
|
70 | + */ |
|
71 | + public function getSection() { |
|
72 | + return 'additional'; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return int whether the form should be rather on the top or bottom of |
|
77 | - * the admin section. The forms are arranged in ascending order of the |
|
78 | - * priority values. It is required to return a value between 0 and 100. |
|
79 | - * |
|
80 | - * E.g.: 70 |
|
81 | - */ |
|
82 | - public function getPriority() { |
|
83 | - return 5; |
|
84 | - } |
|
75 | + /** |
|
76 | + * @return int whether the form should be rather on the top or bottom of |
|
77 | + * the admin section. The forms are arranged in ascending order of the |
|
78 | + * priority values. It is required to return a value between 0 and 100. |
|
79 | + * |
|
80 | + * E.g.: 70 |
|
81 | + */ |
|
82 | + public function getPriority() { |
|
83 | + return 5; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | } |
@@ -30,11 +30,11 @@ |
||
30 | 30 | $filename = $_GET["file"]; |
31 | 31 | |
32 | 32 | if(!\OC\Files\Filesystem::file_exists($filename)) { |
33 | - header("HTTP/1.0 404 Not Found"); |
|
34 | - $tmpl = new OCP\Template( '', '404', 'guest' ); |
|
35 | - $tmpl->assign('file', $filename); |
|
36 | - $tmpl->printPage(); |
|
37 | - exit; |
|
33 | + header("HTTP/1.0 404 Not Found"); |
|
34 | + $tmpl = new OCP\Template( '', '404', 'guest' ); |
|
35 | + $tmpl->assign('file', $filename); |
|
36 | + $tmpl->printPage(); |
|
37 | + exit; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $ftype=\OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType( $filename )); |
@@ -29,60 +29,60 @@ |
||
29 | 29 | |
30 | 30 | $application = new Application(); |
31 | 31 | $application->registerRoutes( |
32 | - $this, |
|
33 | - array( |
|
34 | - 'routes' => array( |
|
35 | - array( |
|
36 | - 'name' => 'API#getThumbnail', |
|
37 | - 'url' => '/api/v1/thumbnail/{x}/{y}/{file}', |
|
38 | - 'verb' => 'GET', |
|
39 | - 'requirements' => array('file' => '.+') |
|
40 | - ), |
|
41 | - array( |
|
42 | - 'name' => 'API#updateFileTags', |
|
43 | - 'url' => '/api/v1/files/{path}', |
|
44 | - 'verb' => 'POST', |
|
45 | - 'requirements' => array('path' => '.+'), |
|
46 | - ), |
|
47 | - array( |
|
48 | - 'name' => 'API#getRecentFiles', |
|
49 | - 'url' => '/api/v1/recent/', |
|
50 | - 'verb' => 'GET' |
|
51 | - ), |
|
52 | - array( |
|
53 | - 'name' => 'API#updateFileSorting', |
|
54 | - 'url' => '/api/v1/sorting', |
|
55 | - 'verb' => 'POST' |
|
56 | - ), |
|
57 | - array( |
|
58 | - 'name' => 'API#showHiddenFiles', |
|
59 | - 'url' => '/api/v1/showhidden', |
|
60 | - 'verb' => 'POST' |
|
61 | - ), |
|
62 | - [ |
|
63 | - 'name' => 'view#index', |
|
64 | - 'url' => '/', |
|
65 | - 'verb' => 'GET', |
|
66 | - ], |
|
67 | - [ |
|
68 | - 'name' => 'settings#setMaxUploadSize', |
|
69 | - 'url' => '/settings/maxUpload', |
|
70 | - 'verb' => 'POST', |
|
71 | - ] |
|
72 | - ) |
|
73 | - ) |
|
32 | + $this, |
|
33 | + array( |
|
34 | + 'routes' => array( |
|
35 | + array( |
|
36 | + 'name' => 'API#getThumbnail', |
|
37 | + 'url' => '/api/v1/thumbnail/{x}/{y}/{file}', |
|
38 | + 'verb' => 'GET', |
|
39 | + 'requirements' => array('file' => '.+') |
|
40 | + ), |
|
41 | + array( |
|
42 | + 'name' => 'API#updateFileTags', |
|
43 | + 'url' => '/api/v1/files/{path}', |
|
44 | + 'verb' => 'POST', |
|
45 | + 'requirements' => array('path' => '.+'), |
|
46 | + ), |
|
47 | + array( |
|
48 | + 'name' => 'API#getRecentFiles', |
|
49 | + 'url' => '/api/v1/recent/', |
|
50 | + 'verb' => 'GET' |
|
51 | + ), |
|
52 | + array( |
|
53 | + 'name' => 'API#updateFileSorting', |
|
54 | + 'url' => '/api/v1/sorting', |
|
55 | + 'verb' => 'POST' |
|
56 | + ), |
|
57 | + array( |
|
58 | + 'name' => 'API#showHiddenFiles', |
|
59 | + 'url' => '/api/v1/showhidden', |
|
60 | + 'verb' => 'POST' |
|
61 | + ), |
|
62 | + [ |
|
63 | + 'name' => 'view#index', |
|
64 | + 'url' => '/', |
|
65 | + 'verb' => 'GET', |
|
66 | + ], |
|
67 | + [ |
|
68 | + 'name' => 'settings#setMaxUploadSize', |
|
69 | + 'url' => '/settings/maxUpload', |
|
70 | + 'verb' => 'POST', |
|
71 | + ] |
|
72 | + ) |
|
73 | + ) |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | /** @var $this \OC\Route\Router */ |
77 | 77 | |
78 | 78 | $this->create('files_ajax_download', 'ajax/download.php') |
79 | - ->actionInclude('files/ajax/download.php'); |
|
79 | + ->actionInclude('files/ajax/download.php'); |
|
80 | 80 | $this->create('files_ajax_getstoragestats', 'ajax/getstoragestats.php') |
81 | - ->actionInclude('files/ajax/getstoragestats.php'); |
|
81 | + ->actionInclude('files/ajax/getstoragestats.php'); |
|
82 | 82 | $this->create('files_ajax_list', 'ajax/list.php') |
83 | - ->actionInclude('files/ajax/list.php'); |
|
83 | + ->actionInclude('files/ajax/list.php'); |
|
84 | 84 | |
85 | 85 | $this->create('download', 'download{file}') |
86 | - ->requirements(array('file' => '.*')) |
|
87 | - ->actionInclude('files/download.php'); |
|
86 | + ->requirements(array('file' => '.*')) |
|
87 | + ->actionInclude('files/download.php'); |
|
88 | 88 |
@@ -39,21 +39,21 @@ |
||
39 | 39 | $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
40 | 40 | |
41 | 41 | \OCA\Files\App::getNavigationManager()->add(function () use ($l) { |
42 | - return [ |
|
43 | - 'id' => 'files', |
|
44 | - 'appname' => 'files', |
|
45 | - 'script' => 'list.php', |
|
46 | - 'order' => 0, |
|
47 | - 'name' => $l->t('All files'), |
|
48 | - ]; |
|
42 | + return [ |
|
43 | + 'id' => 'files', |
|
44 | + 'appname' => 'files', |
|
45 | + 'script' => 'list.php', |
|
46 | + 'order' => 0, |
|
47 | + 'name' => $l->t('All files'), |
|
48 | + ]; |
|
49 | 49 | }); |
50 | 50 | |
51 | 51 | \OCA\Files\App::getNavigationManager()->add(function () use ($l) { |
52 | - return [ |
|
53 | - 'id' => 'recent', |
|
54 | - 'appname' => 'files', |
|
55 | - 'script' => 'recentlist.php', |
|
56 | - 'order' => 2, |
|
57 | - 'name' => $l->t('Recent'), |
|
58 | - ]; |
|
52 | + return [ |
|
53 | + 'id' => 'recent', |
|
54 | + 'appname' => 'files', |
|
55 | + 'script' => 'recentlist.php', |
|
56 | + 'order' => 2, |
|
57 | + 'name' => $l->t('Recent'), |
|
58 | + ]; |
|
59 | 59 | }); |
@@ -9,19 +9,19 @@ |
||
9 | 9 | <p> |
10 | 10 | <select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser"> |
11 | 11 | <?php if(count($_['serverConfigurationPrefixes']) === 0 ) { |
12 | - ?> |
|
12 | + ?> |
|
13 | 13 | <option value="" selected><?php p($l->t('1. Server'));?></option>'); |
14 | 14 | <?php |
15 | - } else { |
|
16 | - $i = 1; |
|
17 | - $sel = ' selected'; |
|
18 | - foreach($_['serverConfigurationPrefixes'] as $prefix) { |
|
19 | - ?> |
|
15 | + } else { |
|
16 | + $i = 1; |
|
17 | + $sel = ' selected'; |
|
18 | + foreach($_['serverConfigurationPrefixes'] as $prefix) { |
|
19 | + ?> |
|
20 | 20 | <option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option> |
21 | 21 | <?php |
22 | - } |
|
23 | - } |
|
24 | - ?> |
|
22 | + } |
|
23 | + } |
|
24 | + ?> |
|
25 | 25 | </select> |
26 | 26 | <button type="button" id="ldap_action_add_configuration" |
27 | 27 | name="ldap_action_add_configuration" class="icon-add icon-default-style" |
@@ -34,16 +34,16 @@ |
||
34 | 34 | $subject = (string)$_POST['ldap_clear_mapping']; |
35 | 35 | $mapping = null; |
36 | 36 | if($subject === 'user') { |
37 | - $mapping = new UserMapping(\OC::$server->getDatabaseConnection()); |
|
37 | + $mapping = new UserMapping(\OC::$server->getDatabaseConnection()); |
|
38 | 38 | } else if($subject === 'group') { |
39 | - $mapping = new GroupMapping(\OC::$server->getDatabaseConnection()); |
|
39 | + $mapping = new GroupMapping(\OC::$server->getDatabaseConnection()); |
|
40 | 40 | } |
41 | 41 | try { |
42 | - if(is_null($mapping) || !$mapping->clear()) { |
|
43 | - $l = \OC::$server->getL10N('user_ldap'); |
|
44 | - throw new \Exception($l->t('Failed to clear the mappings.')); |
|
45 | - } |
|
46 | - OCP\JSON::success(); |
|
42 | + if(is_null($mapping) || !$mapping->clear()) { |
|
43 | + $l = \OC::$server->getL10N('user_ldap'); |
|
44 | + throw new \Exception($l->t('Failed to clear the mappings.')); |
|
45 | + } |
|
46 | + OCP\JSON::success(); |
|
47 | 47 | } catch (\Exception $e) { |
48 | - OCP\JSON::error(array('message' => $e->getMessage())); |
|
48 | + OCP\JSON::error(array('message' => $e->getMessage())); |
|
49 | 49 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | |
38 | 38 | |
39 | 39 | try { |
40 | - $configurationOk = true; |
|
41 | - $conf = $connection->getConfiguration(); |
|
42 | - if ($conf['ldap_configuration_active'] === '0') { |
|
43 | - //needs to be true, otherwise it will also fail with an irritating message |
|
44 | - $conf['ldap_configuration_active'] = '1'; |
|
45 | - $configurationOk = $connection->setConfiguration($conf); |
|
46 | - } |
|
47 | - if ($configurationOk) { |
|
48 | - //Configuration is okay |
|
49 | - /* |
|
40 | + $configurationOk = true; |
|
41 | + $conf = $connection->getConfiguration(); |
|
42 | + if ($conf['ldap_configuration_active'] === '0') { |
|
43 | + //needs to be true, otherwise it will also fail with an irritating message |
|
44 | + $conf['ldap_configuration_active'] = '1'; |
|
45 | + $configurationOk = $connection->setConfiguration($conf); |
|
46 | + } |
|
47 | + if ($configurationOk) { |
|
48 | + //Configuration is okay |
|
49 | + /* |
|
50 | 50 | * Clossing the session since it won't be used from this point on. There might be a potential |
51 | 51 | * race condition if a second request is made: either this request or the other might not |
52 | 52 | * contact the LDAP backup server the first time when it should, but there shouldn't be any |
53 | 53 | * problem with that other than the extra connection. |
54 | 54 | */ |
55 | - \OC::$server->getSession()->close(); |
|
56 | - if ($connection->bind()) { |
|
57 | - /* |
|
55 | + \OC::$server->getSession()->close(); |
|
56 | + if ($connection->bind()) { |
|
57 | + /* |
|
58 | 58 | * This shiny if block is an ugly hack to find out whether anonymous |
59 | 59 | * bind is possible on AD or not. Because AD happily and constantly |
60 | 60 | * replies with success to any anonymous bind request, we need to |
@@ -63,24 +63,24 @@ discard block |
||
63 | 63 | * exception by the LDAP wrapper. We catch this. Other cases may |
64 | 64 | * pass (like e.g. expected syntax error). |
65 | 65 | */ |
66 | - try { |
|
67 | - $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn')); |
|
68 | - } catch (\Exception $e) { |
|
69 | - if($e->getCode() === 1) { |
|
70 | - OCP\JSON::error(array('message' => $l->t('The configuration is invalid: anonymous bind is not allowed.'))); |
|
71 | - exit; |
|
72 | - } |
|
73 | - } |
|
74 | - OCP\JSON::success(array('message' |
|
75 | - => $l->t('The configuration is valid and the connection could be established!'))); |
|
76 | - } else { |
|
77 | - OCP\JSON::error(array('message' |
|
78 | - => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'))); |
|
79 | - } |
|
80 | - } else { |
|
81 | - OCP\JSON::error(array('message' |
|
82 | - => $l->t('The configuration is invalid. Please have a look at the logs for further details.'))); |
|
83 | - } |
|
66 | + try { |
|
67 | + $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn')); |
|
68 | + } catch (\Exception $e) { |
|
69 | + if($e->getCode() === 1) { |
|
70 | + OCP\JSON::error(array('message' => $l->t('The configuration is invalid: anonymous bind is not allowed.'))); |
|
71 | + exit; |
|
72 | + } |
|
73 | + } |
|
74 | + OCP\JSON::success(array('message' |
|
75 | + => $l->t('The configuration is valid and the connection could be established!'))); |
|
76 | + } else { |
|
77 | + OCP\JSON::error(array('message' |
|
78 | + => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'))); |
|
79 | + } |
|
80 | + } else { |
|
81 | + OCP\JSON::error(array('message' |
|
82 | + => $l->t('The configuration is invalid. Please have a look at the logs for further details.'))); |
|
83 | + } |
|
84 | 84 | } catch (\Exception $e) { |
85 | - OCP\JSON::error(array('message' => $e->getMessage())); |
|
85 | + OCP\JSON::error(array('message' => $e->getMessage())); |
|
86 | 86 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
35 | 35 | $configuration = $connection->getConfiguration(); |
36 | 36 | if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') { |
37 | - // hide password |
|
38 | - $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
37 | + // hide password |
|
38 | + $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
39 | 39 | } |
40 | 40 | OCP\JSON::success(array('configuration' => $configuration)); |