2013-09-27 00:31:57 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Alexander Bergolth <leo@strike.wu.ac.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Alex Weirig <alex.weirig@technolink.lu>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author blizzz <blizzz@arthur-schiwon.de>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
2015-10-26 15:54:55 +03:00
|
|
|
* @author Lennart Rosam <hello@takuto.de>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-08-30 12:43:29 +03:00
|
|
|
* @author Roger Szabo <roger.szabo@web.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
|
|
|
|
* @author Xuanwo <xuanwo@yunify.com>
|
2013-09-27 00:31:57 +04:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
2013-09-27 00:31:57 +04:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2013-09-27 00:31:57 +04:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2013-09-27 00:31:57 +04:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 13:44:34 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2013-09-27 00:31:57 +04:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2013-09-27 00:31:57 +04:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2016-05-12 17:37:49 +03:00
|
|
|
namespace OCA\User_LDAP;
|
2013-09-27 00:31:57 +04:00
|
|
|
|
2015-12-17 14:29:55 +03:00
|
|
|
/**
|
|
|
|
* @property int ldapPagingSize holds an integer
|
2018-07-04 01:10:43 +03:00
|
|
|
* @property string ldapUserAvatarRule
|
2015-12-17 14:29:55 +03:00
|
|
|
*/
|
2013-09-27 00:31:57 +04:00
|
|
|
class Configuration {
|
2020-04-10 17:54:27 +03:00
|
|
|
public const AVATAR_PREFIX_DEFAULT = 'default';
|
|
|
|
public const AVATAR_PREFIX_NONE = 'none';
|
|
|
|
public const AVATAR_PREFIX_DATA_ATTRIBUTE = 'data:';
|
2018-07-04 01:10:43 +03:00
|
|
|
|
2020-06-24 14:09:15 +03:00
|
|
|
public const LDAP_SERVER_FEATURE_UNKNOWN = 'unknown';
|
|
|
|
public const LDAP_SERVER_FEATURE_AVAILABLE = 'available';
|
|
|
|
public const LDAP_SERVER_FEATURE_UNAVAILABLE = 'unavailable';
|
|
|
|
|
2013-09-27 00:31:57 +04:00
|
|
|
protected $configPrefix = null;
|
|
|
|
protected $configRead = false;
|
2017-07-06 00:13:15 +03:00
|
|
|
/**
|
|
|
|
* @var string[] pre-filled with one reference key so that at least one entry is written on save request and
|
|
|
|
* the config ID is registered
|
|
|
|
*/
|
|
|
|
protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive'];
|
2013-09-27 00:31:57 +04:00
|
|
|
|
|
|
|
//settings
|
2020-03-26 11:30:18 +03:00
|
|
|
protected $config = [
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapHost' => null,
|
|
|
|
'ldapPort' => null,
|
|
|
|
'ldapBackupHost' => null,
|
|
|
|
'ldapBackupPort' => null,
|
|
|
|
'ldapBase' => null,
|
|
|
|
'ldapBaseUsers' => null,
|
|
|
|
'ldapBaseGroups' => null,
|
|
|
|
'ldapAgentName' => null,
|
|
|
|
'ldapAgentPassword' => null,
|
|
|
|
'ldapTLS' => null,
|
|
|
|
'turnOffCertCheck' => null,
|
|
|
|
'ldapIgnoreNamingRules' => null,
|
|
|
|
'ldapUserDisplayName' => null,
|
2016-02-03 15:16:55 +03:00
|
|
|
'ldapUserDisplayName2' => null,
|
2018-07-04 01:10:43 +03:00
|
|
|
'ldapUserAvatarRule' => null,
|
2017-03-18 09:56:24 +03:00
|
|
|
'ldapGidNumber' => null,
|
2013-10-04 18:33:37 +04:00
|
|
|
'ldapUserFilterObjectclass' => null,
|
2013-10-04 20:11:44 +04:00
|
|
|
'ldapUserFilterGroups' => null,
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapUserFilter' => null,
|
2013-11-20 02:58:08 +04:00
|
|
|
'ldapUserFilterMode' => null,
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapGroupFilter' => null,
|
2013-11-20 02:58:08 +04:00
|
|
|
'ldapGroupFilterMode' => null,
|
2013-10-10 00:00:36 +04:00
|
|
|
'ldapGroupFilterObjectclass' => null,
|
|
|
|
'ldapGroupFilterGroups' => null,
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapGroupDisplayName' => null,
|
|
|
|
'ldapGroupMemberAssocAttr' => null,
|
|
|
|
'ldapLoginFilter' => null,
|
2013-11-20 02:58:08 +04:00
|
|
|
'ldapLoginFilterMode' => null,
|
2013-10-09 01:47:57 +04:00
|
|
|
'ldapLoginFilterEmail' => null,
|
|
|
|
'ldapLoginFilterUsername' => null,
|
|
|
|
'ldapLoginFilterAttributes' => null,
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapQuotaAttribute' => null,
|
|
|
|
'ldapQuotaDefault' => null,
|
|
|
|
'ldapEmailAttribute' => null,
|
|
|
|
'ldapCacheTTL' => null,
|
2013-10-17 21:40:59 +04:00
|
|
|
'ldapUuidUserAttribute' => 'auto',
|
|
|
|
'ldapUuidGroupAttribute' => 'auto',
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapOverrideMainServer' => false,
|
|
|
|
'ldapConfigurationActive' => false,
|
|
|
|
'ldapAttributesForUserSearch' => null,
|
|
|
|
'ldapAttributesForGroupSearch' => null,
|
2014-10-07 18:29:06 +04:00
|
|
|
'ldapExperiencedAdmin' => false,
|
2013-09-27 00:31:57 +04:00
|
|
|
'homeFolderNamingRule' => null,
|
2013-10-08 20:27:36 +04:00
|
|
|
'hasMemberOfFilterSupport' => false,
|
2015-06-03 18:37:36 +03:00
|
|
|
'useMemberOfToDetectMembership' => true,
|
2013-09-27 00:31:57 +04:00
|
|
|
'ldapExpertUsernameAttr' => null,
|
2013-10-17 21:40:59 +04:00
|
|
|
'ldapExpertUUIDUserAttr' => null,
|
|
|
|
'ldapExpertUUIDGroupAttr' => null,
|
2013-11-21 20:02:37 +04:00
|
|
|
'lastJpegPhotoLookup' => null,
|
2013-12-06 19:46:52 +04:00
|
|
|
'ldapNestedGroups' => false,
|
2014-03-04 20:23:04 +04:00
|
|
|
'ldapPagingSize' => null,
|
2016-08-30 12:43:29 +03:00
|
|
|
'turnOnPasswordChange' => false,
|
2016-01-14 15:26:40 +03:00
|
|
|
'ldapDynamicGroupMemberURL' => null,
|
2017-03-31 10:16:22 +03:00
|
|
|
'ldapDefaultPPolicyDN' => null,
|
2019-02-13 02:14:56 +03:00
|
|
|
'ldapExtStorageHomeAttribute' => null,
|
2020-06-24 14:09:15 +03:00
|
|
|
'ldapMatchingRuleInChainState' => self::LDAP_SERVER_FEATURE_UNKNOWN,
|
2020-03-26 11:30:18 +03:00
|
|
|
];
|
2013-09-27 00:31:57 +04:00
|
|
|
|
2014-02-06 19:30:58 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $configPrefix
|
2014-05-11 17:17:27 +04:00
|
|
|
* @param bool $autoRead
|
2014-02-06 19:30:58 +04:00
|
|
|
*/
|
2014-05-11 17:17:27 +04:00
|
|
|
public function __construct($configPrefix, $autoRead = true) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$this->configPrefix = $configPrefix;
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($autoRead) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$this->readConfiguration();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $name
|
2016-08-17 10:46:54 +03:00
|
|
|
* @return mixed|null
|
2014-05-11 17:17:27 +04:00
|
|
|
*/
|
2013-09-27 00:31:57 +04:00
|
|
|
public function __get($name) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if (isset($this->config[$name])) {
|
2013-09-27 00:31:57 +04:00
|
|
|
return $this->config[$name];
|
|
|
|
}
|
2016-08-17 10:46:54 +03:00
|
|
|
return null;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $name
|
|
|
|
* @param mixed $value
|
2014-05-11 17:17:27 +04:00
|
|
|
*/
|
2013-09-27 00:31:57 +04:00
|
|
|
public function __set($name, $value) {
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->setConfiguration([$name => $value]);
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-09-27 00:31:57 +04:00
|
|
|
public function getConfiguration() {
|
|
|
|
return $this->config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-19 19:50:53 +04:00
|
|
|
* set LDAP configuration with values delivered by an array, not read
|
2013-09-27 00:31:57 +04:00
|
|
|
* from configuration. It does not save the configuration! To do so, you
|
|
|
|
* must call saveConfiguration afterwards.
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param array $config array that holds the config parameters in an associated
|
2013-09-27 00:31:57 +04:00
|
|
|
* array
|
2014-05-11 17:17:27 +04:00
|
|
|
* @param array &$applied optional; array where the set fields will be given to
|
2014-02-06 19:30:58 +04:00
|
|
|
* @return false|null
|
2013-09-27 00:31:57 +04:00
|
|
|
*/
|
|
|
|
public function setConfiguration($config, &$applied = null) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if (!is_array($config)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cta = $this->getConfigTranslationArray();
|
2020-04-10 15:19:56 +03:00
|
|
|
foreach ($config as $inputKey => $val) {
|
|
|
|
if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) {
|
2014-05-11 17:17:27 +04:00
|
|
|
$key = $cta[$inputKey];
|
2020-04-10 15:19:56 +03:00
|
|
|
} elseif (array_key_exists($inputKey, $this->config)) {
|
2014-05-11 17:17:27 +04:00
|
|
|
$key = $inputKey;
|
2013-09-27 00:31:57 +04:00
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$setMethod = 'setValue';
|
2020-04-10 15:19:56 +03:00
|
|
|
switch ($key) {
|
2015-10-02 18:40:38 +03:00
|
|
|
case 'ldapAgentPassword':
|
|
|
|
$setMethod = 'setRawValue';
|
|
|
|
break;
|
2013-09-27 00:31:57 +04:00
|
|
|
case 'homeFolderNamingRule':
|
2015-10-14 23:35:46 +03:00
|
|
|
$trimmedVal = trim($val);
|
2016-09-23 01:30:57 +03:00
|
|
|
if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
|
2015-10-14 23:35:46 +03:00
|
|
|
$val = 'attr:'.$trimmedVal;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
2013-12-13 02:09:31 +04:00
|
|
|
break;
|
2013-09-27 00:31:57 +04:00
|
|
|
case 'ldapBase':
|
|
|
|
case 'ldapBaseUsers':
|
|
|
|
case 'ldapBaseGroups':
|
|
|
|
case 'ldapAttributesForUserSearch':
|
|
|
|
case 'ldapAttributesForGroupSearch':
|
2013-10-04 18:33:37 +04:00
|
|
|
case 'ldapUserFilterObjectclass':
|
2013-10-04 20:11:44 +04:00
|
|
|
case 'ldapUserFilterGroups':
|
2013-10-10 00:00:36 +04:00
|
|
|
case 'ldapGroupFilterObjectclass':
|
|
|
|
case 'ldapGroupFilterGroups':
|
2013-10-09 01:47:57 +04:00
|
|
|
case 'ldapLoginFilterAttributes':
|
2013-09-27 00:31:57 +04:00
|
|
|
$setMethod = 'setMultiLine';
|
2013-12-13 02:09:31 +04:00
|
|
|
break;
|
|
|
|
}
|
2015-10-02 18:40:38 +03:00
|
|
|
$this->$setMethod($key, $val);
|
2020-04-10 15:19:56 +03:00
|
|
|
if (is_array($applied)) {
|
2014-05-11 17:17:27 +04:00
|
|
|
$applied[] = $inputKey;
|
2017-06-30 12:12:33 +03:00
|
|
|
// storing key as index avoids duplication, and as value for simplicity
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
2017-07-06 16:21:27 +03:00
|
|
|
$this->unsavedChanges[$key] = $key;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
2016-08-17 10:46:54 +03:00
|
|
|
return null;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function readConfiguration() {
|
2020-04-10 15:19:56 +03:00
|
|
|
if (!$this->configRead && !is_null($this->configPrefix)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$cta = array_flip($this->getConfigTranslationArray());
|
2020-04-10 15:19:56 +03:00
|
|
|
foreach ($this->config as $key => $val) {
|
|
|
|
if (!isset($cta[$key])) {
|
2013-09-27 00:31:57 +04:00
|
|
|
//some are determined
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-11 17:17:27 +04:00
|
|
|
$dbKey = $cta[$key];
|
2020-04-10 15:19:56 +03:00
|
|
|
switch ($key) {
|
2013-09-27 00:31:57 +04:00
|
|
|
case 'ldapBase':
|
|
|
|
case 'ldapBaseUsers':
|
|
|
|
case 'ldapBaseGroups':
|
|
|
|
case 'ldapAttributesForUserSearch':
|
|
|
|
case 'ldapAttributesForGroupSearch':
|
2013-10-04 18:33:37 +04:00
|
|
|
case 'ldapUserFilterObjectclass':
|
2013-10-04 20:11:44 +04:00
|
|
|
case 'ldapUserFilterGroups':
|
2013-10-10 00:00:36 +04:00
|
|
|
case 'ldapGroupFilterObjectclass':
|
|
|
|
case 'ldapGroupFilterGroups':
|
2013-10-09 01:47:57 +04:00
|
|
|
case 'ldapLoginFilterAttributes':
|
2013-09-27 00:31:57 +04:00
|
|
|
$readMethod = 'getMultiLine';
|
|
|
|
break;
|
|
|
|
case 'ldapIgnoreNamingRules':
|
|
|
|
$readMethod = 'getSystemValue';
|
2014-05-11 17:17:27 +04:00
|
|
|
$dbKey = $key;
|
2013-09-27 00:31:57 +04:00
|
|
|
break;
|
|
|
|
case 'ldapAgentPassword':
|
|
|
|
$readMethod = 'getPwd';
|
|
|
|
break;
|
2016-02-03 15:16:55 +03:00
|
|
|
case 'ldapUserDisplayName2':
|
2013-09-27 00:31:57 +04:00
|
|
|
case 'ldapGroupDisplayName':
|
|
|
|
$readMethod = 'getLcValue';
|
|
|
|
break;
|
LDAP Wizard Overhaul
wizard refactor
reimplement save spinners and cursor
implement Port detector
introduced detector queue, added base dn detector
disable input fields when detectors are running
introduce spinners for fields that are being updated by detector
cache jq element objects
consolidate processing of detector results in generic / abstract base class
display notification if a detector discovered a problem
don't run base dn detector if a base is configured
reset detector queue on configuration switch
implement functionality check and update of status indicator
document ConfigModel
jsdoc for controller and main view
more documentation
implement the user filter tab view
so far the multiselects get initialized (not filled yet) and the mode can be switched.
mode is also restored.
reintroduce filter switch confirmation in admin XP mode
new detector for user object classes. so we also load user object classes if necessary and are able to save and show the setting.
multiselect trigger save actions now on close only
show spinners automatically, when a detector is running
20k limit for object classes preselection test
adjust wordings, fix grammar
add group (for users tab) detector
also includes wording fixes
error presentation moved from detectors to view, where it belongs
add info label to users page
missing wording changes
show effective LDAP filter in Assisted Mode
add user filter detector
implement count button for users and limit all count actions to 1001 for performance reasons
make port field a bit bigger. not perfect though.
do not detect port automatically
implement login filter tab view
only load features in assisted mode and don't enable assisted fields while in raw mode
add tooltips on login filter checkbox options for better understanding
permanently show filter on login tab
and also compile login filter in assisted mode
test/verify button on login attributes tab, with backend changes.
only run wizard requests if your an active tab. also run compile filter requests when switching to assisted mode
underline toggle filter links to stress that they are clickable
unity user and group tab functionality in common abstract class, add group filter tab view. only detectors and template adjustments left to have group tab implementation complete
add object class and group detector for groups as well as filter composer
show ldap filter permanently on groups tab
introduce input element that can deal better with many groups, will be used with > 40
fix disabling complex group chooser while detection is running
hide complex group chooser on config switch
fix few more issues with complex chooser
make complex group chooser available on Users tab as well
detect base dn improvements/changes:
- do not look for Base DN automatically, offer a button instead
- fix for alternative way to detect a base dn (if agent dn is not given)
- do not trigger filter composers on config switch
Changes with configuration chooser controls
- "New" was removed out of the configuration list
- and split into buttons "add" and "copy"
- delete button is also now an icon
add test button for Base DN
reimplement advanced tab. The save button is gone.
reimplement expert tab
remove unused methods
implement mail attribute detector
implement user display name attribute detection
implement member group association detector
replace text input with textarea for raw filter input
finish functionality check
auto-enable good configurations, as it was before
cleanup
move save confirmation handling to base class, reduces code duplication
enable tabs only if no running save processes are left.
move onConfigLoaded to base class, avoids code duplication
simplify, save LOCs
Test Configuration button to be dealt with in main view as it is a cross-tab element
require detectorQueue in constructor
cleanup
put bootstrap into a function and thus make it testable
get rid of old stuff
2015-03-03 13:56:03 +03:00
|
|
|
case 'ldapUserDisplayName':
|
2013-09-27 00:31:57 +04:00
|
|
|
default:
|
LDAP Wizard Overhaul
wizard refactor
reimplement save spinners and cursor
implement Port detector
introduced detector queue, added base dn detector
disable input fields when detectors are running
introduce spinners for fields that are being updated by detector
cache jq element objects
consolidate processing of detector results in generic / abstract base class
display notification if a detector discovered a problem
don't run base dn detector if a base is configured
reset detector queue on configuration switch
implement functionality check and update of status indicator
document ConfigModel
jsdoc for controller and main view
more documentation
implement the user filter tab view
so far the multiselects get initialized (not filled yet) and the mode can be switched.
mode is also restored.
reintroduce filter switch confirmation in admin XP mode
new detector for user object classes. so we also load user object classes if necessary and are able to save and show the setting.
multiselect trigger save actions now on close only
show spinners automatically, when a detector is running
20k limit for object classes preselection test
adjust wordings, fix grammar
add group (for users tab) detector
also includes wording fixes
error presentation moved from detectors to view, where it belongs
add info label to users page
missing wording changes
show effective LDAP filter in Assisted Mode
add user filter detector
implement count button for users and limit all count actions to 1001 for performance reasons
make port field a bit bigger. not perfect though.
do not detect port automatically
implement login filter tab view
only load features in assisted mode and don't enable assisted fields while in raw mode
add tooltips on login filter checkbox options for better understanding
permanently show filter on login tab
and also compile login filter in assisted mode
test/verify button on login attributes tab, with backend changes.
only run wizard requests if your an active tab. also run compile filter requests when switching to assisted mode
underline toggle filter links to stress that they are clickable
unity user and group tab functionality in common abstract class, add group filter tab view. only detectors and template adjustments left to have group tab implementation complete
add object class and group detector for groups as well as filter composer
show ldap filter permanently on groups tab
introduce input element that can deal better with many groups, will be used with > 40
fix disabling complex group chooser while detection is running
hide complex group chooser on config switch
fix few more issues with complex chooser
make complex group chooser available on Users tab as well
detect base dn improvements/changes:
- do not look for Base DN automatically, offer a button instead
- fix for alternative way to detect a base dn (if agent dn is not given)
- do not trigger filter composers on config switch
Changes with configuration chooser controls
- "New" was removed out of the configuration list
- and split into buttons "add" and "copy"
- delete button is also now an icon
add test button for Base DN
reimplement advanced tab. The save button is gone.
reimplement expert tab
remove unused methods
implement mail attribute detector
implement user display name attribute detection
implement member group association detector
replace text input with textarea for raw filter input
finish functionality check
auto-enable good configurations, as it was before
cleanup
move save confirmation handling to base class, reduces code duplication
enable tabs only if no running save processes are left.
move onConfigLoaded to base class, avoids code duplication
simplify, save LOCs
Test Configuration button to be dealt with in main view as it is a cross-tab element
require detectorQueue in constructor
cleanup
put bootstrap into a function and thus make it testable
get rid of old stuff
2015-03-03 13:56:03 +03:00
|
|
|
// user display name does not lower case because
|
|
|
|
// we rely on an upper case N as indicator whether to
|
|
|
|
// auto-detect it or not. FIXME
|
2013-09-27 00:31:57 +04:00
|
|
|
$readMethod = 'getValue';
|
|
|
|
break;
|
|
|
|
}
|
2014-05-11 17:17:27 +04:00
|
|
|
$this->config[$key] = $this->$readMethod($dbKey);
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
$this->configRead = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-06-30 12:12:33 +03:00
|
|
|
* saves the current config changes in the database
|
2013-09-27 00:31:57 +04:00
|
|
|
*/
|
|
|
|
public function saveConfiguration() {
|
|
|
|
$cta = array_flip($this->getConfigTranslationArray());
|
2020-04-10 15:19:56 +03:00
|
|
|
foreach ($this->unsavedChanges as $key) {
|
2017-06-30 12:12:33 +03:00
|
|
|
$value = $this->config[$key];
|
2013-09-27 00:31:57 +04:00
|
|
|
switch ($key) {
|
|
|
|
case 'ldapAgentPassword':
|
|
|
|
$value = base64_encode($value);
|
|
|
|
break;
|
|
|
|
case 'ldapBase':
|
|
|
|
case 'ldapBaseUsers':
|
|
|
|
case 'ldapBaseGroups':
|
|
|
|
case 'ldapAttributesForUserSearch':
|
|
|
|
case 'ldapAttributesForGroupSearch':
|
2013-10-04 18:33:37 +04:00
|
|
|
case 'ldapUserFilterObjectclass':
|
2013-10-04 20:11:44 +04:00
|
|
|
case 'ldapUserFilterGroups':
|
2013-10-10 00:00:36 +04:00
|
|
|
case 'ldapGroupFilterObjectclass':
|
|
|
|
case 'ldapGroupFilterGroups':
|
2013-10-09 01:47:57 +04:00
|
|
|
case 'ldapLoginFilterAttributes':
|
2020-04-10 15:19:56 +03:00
|
|
|
if (is_array($value)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$value = implode("\n", $value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//following options are not stored but detected, skip them
|
|
|
|
case 'ldapIgnoreNamingRules':
|
2013-10-17 21:40:59 +04:00
|
|
|
case 'ldapUuidUserAttribute':
|
|
|
|
case 'ldapUuidGroupAttribute':
|
2013-09-27 00:31:57 +04:00
|
|
|
continue 2;
|
|
|
|
}
|
2020-04-10 15:19:56 +03:00
|
|
|
if (is_null($value)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$value = '';
|
|
|
|
}
|
|
|
|
$this->saveValue($cta[$key], $value);
|
|
|
|
}
|
2017-10-31 21:42:17 +03:00
|
|
|
$this->saveValue('_lastChange', time());
|
2017-06-30 12:12:33 +03:00
|
|
|
$this->unsavedChanges = [];
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return array|string
|
|
|
|
*/
|
|
|
|
protected function getMultiLine($varName) {
|
|
|
|
$value = $this->getValue($varName);
|
2020-04-10 15:19:56 +03:00
|
|
|
if (empty($value)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$value = '';
|
|
|
|
} else {
|
|
|
|
$value = preg_split('/\r\n|\r|\n/', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2015-08-23 00:06:04 +03:00
|
|
|
* Sets multi-line values as arrays
|
2020-04-09 17:09:23 +03:00
|
|
|
*
|
2015-08-23 00:06:04 +03:00
|
|
|
* @param string $varName name of config-key
|
|
|
|
* @param array|string $value to set
|
2014-05-11 17:17:27 +04:00
|
|
|
*/
|
2015-10-02 18:40:38 +03:00
|
|
|
protected function setMultiLine($varName, $value) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if (empty($value)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$value = '';
|
2020-04-10 11:35:09 +03:00
|
|
|
} elseif (!is_array($value)) {
|
2014-06-03 14:35:18 +04:00
|
|
|
$value = preg_split('/\r\n|\r|\n|;/', $value);
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($value === false) {
|
2013-10-17 22:58:43 +04:00
|
|
|
$value = '';
|
2015-08-23 00:06:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
if (!is_array($value)) {
|
2015-10-02 18:40:38 +03:00
|
|
|
$finalValue = trim($value);
|
|
|
|
} else {
|
|
|
|
$finalValue = [];
|
2020-04-10 15:19:56 +03:00
|
|
|
foreach ($value as $key => $val) {
|
|
|
|
if (is_string($val)) {
|
2015-10-02 18:40:38 +03:00
|
|
|
$val = trim($val);
|
2016-09-23 01:30:57 +03:00
|
|
|
if ($val !== '') {
|
2015-10-02 18:40:38 +03:00
|
|
|
//accidental line breaks are not wanted and can cause
|
|
|
|
// odd behaviour. Thus, away with them.
|
|
|
|
$finalValue[] = $val;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$finalValue[] = $val;
|
2015-08-23 00:06:04 +03:00
|
|
|
}
|
|
|
|
}
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2015-10-02 18:40:38 +03:00
|
|
|
$this->setRawValue($varName, $finalValue);
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getPwd($varName) {
|
|
|
|
return base64_decode($this->getValue($varName));
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getLcValue($varName) {
|
|
|
|
return mb_strtolower($this->getValue($varName), 'UTF-8');
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getSystemValue($varName) {
|
2013-09-27 00:31:57 +04:00
|
|
|
//FIXME: if another system value is added, softcode the default value
|
2017-07-27 14:43:18 +03:00
|
|
|
return \OC::$server->getConfig()->getSystemValue($varName, false);
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getValue($varName) {
|
2013-09-27 00:31:57 +04:00
|
|
|
static $defaults;
|
2020-04-10 15:19:56 +03:00
|
|
|
if (is_null($defaults)) {
|
2013-09-27 00:31:57 +04:00
|
|
|
$defaults = $this->getDefaults();
|
|
|
|
}
|
2018-01-13 16:25:04 +03:00
|
|
|
return \OC::$server->getConfig()->getAppValue('user_ldap',
|
2014-05-11 17:17:27 +04:00
|
|
|
$this->configPrefix.$varName,
|
|
|
|
$defaults[$varName]);
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2015-08-23 00:06:04 +03:00
|
|
|
* Sets a scalar value.
|
2020-04-09 17:09:23 +03:00
|
|
|
*
|
2015-08-23 00:06:04 +03:00
|
|
|
* @param string $varName name of config key
|
|
|
|
* @param mixed $value to set
|
2014-05-11 17:17:27 +04:00
|
|
|
*/
|
2015-10-02 18:40:38 +03:00
|
|
|
protected function setValue($varName, $value) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if (is_string($value)) {
|
2015-08-23 00:06:04 +03:00
|
|
|
$value = trim($value);
|
|
|
|
}
|
|
|
|
$this->config[$varName] = $value;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
2015-10-02 18:40:38 +03:00
|
|
|
/**
|
|
|
|
* Sets a scalar value without trimming.
|
|
|
|
*
|
|
|
|
* @param string $varName name of config key
|
|
|
|
* @param mixed $value to set
|
|
|
|
*/
|
|
|
|
protected function setRawValue($varName, $value) {
|
|
|
|
$this->config[$varName] = $value;
|
|
|
|
}
|
|
|
|
|
2014-05-11 17:17:27 +04:00
|
|
|
/**
|
2014-05-13 15:29:25 +04:00
|
|
|
* @param string $varName
|
|
|
|
* @param string $value
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function saveValue($varName, $value) {
|
2017-01-18 23:13:23 +03:00
|
|
|
\OC::$server->getConfig()->setAppValue(
|
|
|
|
'user_ldap',
|
|
|
|
$this->configPrefix.$varName,
|
|
|
|
$value
|
|
|
|
);
|
|
|
|
return true;
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return array an associative array with the default values. Keys are correspond
|
2013-09-27 00:31:57 +04:00
|
|
|
* to config-value entries in the database table
|
|
|
|
*/
|
|
|
|
public function getDefaults() {
|
2020-03-26 11:30:18 +03:00
|
|
|
return [
|
2020-10-05 16:12:57 +03:00
|
|
|
'ldap_host' => '',
|
|
|
|
'ldap_port' => '',
|
|
|
|
'ldap_backup_host' => '',
|
|
|
|
'ldap_backup_port' => '',
|
|
|
|
'ldap_override_main_server' => '',
|
|
|
|
'ldap_dn' => '',
|
|
|
|
'ldap_agent_password' => '',
|
|
|
|
'ldap_base' => '',
|
|
|
|
'ldap_base_users' => '',
|
|
|
|
'ldap_base_groups' => '',
|
|
|
|
'ldap_userlist_filter' => '',
|
|
|
|
'ldap_user_filter_mode' => 0,
|
|
|
|
'ldap_userfilter_objectclass' => '',
|
|
|
|
'ldap_userfilter_groups' => '',
|
|
|
|
'ldap_login_filter' => '',
|
|
|
|
'ldap_login_filter_mode' => 0,
|
|
|
|
'ldap_loginfilter_email' => 0,
|
|
|
|
'ldap_loginfilter_username' => 1,
|
|
|
|
'ldap_loginfilter_attributes' => '',
|
|
|
|
'ldap_group_filter' => '',
|
|
|
|
'ldap_group_filter_mode' => 0,
|
|
|
|
'ldap_groupfilter_objectclass' => '',
|
|
|
|
'ldap_groupfilter_groups' => '',
|
|
|
|
'ldap_gid_number' => 'gidNumber',
|
|
|
|
'ldap_display_name' => 'displayName',
|
|
|
|
'ldap_user_display_name_2' => '',
|
|
|
|
'ldap_group_display_name' => 'cn',
|
|
|
|
'ldap_tls' => 0,
|
|
|
|
'ldap_quota_def' => '',
|
|
|
|
'ldap_quota_attr' => '',
|
|
|
|
'ldap_email_attr' => '',
|
2019-05-17 17:19:23 +03:00
|
|
|
'ldap_group_member_assoc_attribute' => '',
|
2020-10-05 16:12:57 +03:00
|
|
|
'ldap_cache_ttl' => 600,
|
|
|
|
'ldap_uuid_user_attribute' => 'auto',
|
|
|
|
'ldap_uuid_group_attribute' => 'auto',
|
|
|
|
'home_folder_naming_rule' => '',
|
|
|
|
'ldap_turn_off_cert_check' => 0,
|
|
|
|
'ldap_configuration_active' => 0,
|
|
|
|
'ldap_attributes_for_user_search' => '',
|
|
|
|
'ldap_attributes_for_group_search' => '',
|
|
|
|
'ldap_expert_username_attr' => '',
|
|
|
|
'ldap_expert_uuid_user_attr' => '',
|
|
|
|
'ldap_expert_uuid_group_attr' => '',
|
|
|
|
'has_memberof_filter_support' => 0,
|
2015-06-03 18:37:36 +03:00
|
|
|
'use_memberof_to_detect_membership' => 1,
|
2020-10-05 16:12:57 +03:00
|
|
|
'last_jpegPhoto_lookup' => 0,
|
|
|
|
'ldap_nested_groups' => 0,
|
|
|
|
'ldap_paging_size' => 500,
|
|
|
|
'ldap_turn_on_pwd_change' => 0,
|
|
|
|
'ldap_experienced_admin' => 0,
|
|
|
|
'ldap_dynamic_group_member_url' => '',
|
|
|
|
'ldap_default_ppolicy_dn' => '',
|
|
|
|
'ldap_user_avatar_rule' => 'default',
|
|
|
|
'ldap_ext_storage_home_attribute' => '',
|
2020-06-24 14:09:15 +03:00
|
|
|
'ldap_matching_rule_in_chain_state' => self::LDAP_SERVER_FEATURE_UNKNOWN,
|
2020-03-26 11:30:18 +03:00
|
|
|
];
|
2013-09-27 00:31:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-11 17:17:27 +04:00
|
|
|
* @return array that maps internal variable names to database fields
|
2013-09-27 00:31:57 +04:00
|
|
|
*/
|
|
|
|
public function getConfigTranslationArray() {
|
|
|
|
//TODO: merge them into one representation
|
2020-03-26 11:30:18 +03:00
|
|
|
static $array = [
|
2020-10-05 16:12:57 +03:00
|
|
|
'ldap_host' => 'ldapHost',
|
|
|
|
'ldap_port' => 'ldapPort',
|
|
|
|
'ldap_backup_host' => 'ldapBackupHost',
|
|
|
|
'ldap_backup_port' => 'ldapBackupPort',
|
|
|
|
'ldap_override_main_server' => 'ldapOverrideMainServer',
|
|
|
|
'ldap_dn' => 'ldapAgentName',
|
|
|
|
'ldap_agent_password' => 'ldapAgentPassword',
|
|
|
|
'ldap_base' => 'ldapBase',
|
|
|
|
'ldap_base_users' => 'ldapBaseUsers',
|
|
|
|
'ldap_base_groups' => 'ldapBaseGroups',
|
|
|
|
'ldap_userfilter_objectclass' => 'ldapUserFilterObjectclass',
|
|
|
|
'ldap_userfilter_groups' => 'ldapUserFilterGroups',
|
|
|
|
'ldap_userlist_filter' => 'ldapUserFilter',
|
|
|
|
'ldap_user_filter_mode' => 'ldapUserFilterMode',
|
|
|
|
'ldap_user_avatar_rule' => 'ldapUserAvatarRule',
|
|
|
|
'ldap_login_filter' => 'ldapLoginFilter',
|
|
|
|
'ldap_login_filter_mode' => 'ldapLoginFilterMode',
|
|
|
|
'ldap_loginfilter_email' => 'ldapLoginFilterEmail',
|
|
|
|
'ldap_loginfilter_username' => 'ldapLoginFilterUsername',
|
|
|
|
'ldap_loginfilter_attributes' => 'ldapLoginFilterAttributes',
|
|
|
|
'ldap_group_filter' => 'ldapGroupFilter',
|
|
|
|
'ldap_group_filter_mode' => 'ldapGroupFilterMode',
|
|
|
|
'ldap_groupfilter_objectclass' => 'ldapGroupFilterObjectclass',
|
|
|
|
'ldap_groupfilter_groups' => 'ldapGroupFilterGroups',
|
|
|
|
'ldap_gid_number' => 'ldapGidNumber',
|
|
|
|
'ldap_display_name' => 'ldapUserDisplayName',
|
|
|
|
'ldap_user_display_name_2' => 'ldapUserDisplayName2',
|
|
|
|
'ldap_group_display_name' => 'ldapGroupDisplayName',
|
|
|
|
'ldap_tls' => 'ldapTLS',
|
|
|
|
'ldap_quota_def' => 'ldapQuotaDefault',
|
|
|
|
'ldap_quota_attr' => 'ldapQuotaAttribute',
|
|
|
|
'ldap_email_attr' => 'ldapEmailAttribute',
|
2014-10-08 17:04:29 +04:00
|
|
|
'ldap_group_member_assoc_attribute' => 'ldapGroupMemberAssocAttr',
|
2020-10-05 16:12:57 +03:00
|
|
|
'ldap_cache_ttl' => 'ldapCacheTTL',
|
|
|
|
'home_folder_naming_rule' => 'homeFolderNamingRule',
|
|
|
|
'ldap_turn_off_cert_check' => 'turnOffCertCheck',
|
|
|
|
'ldap_configuration_active' => 'ldapConfigurationActive',
|
|
|
|
'ldap_attributes_for_user_search' => 'ldapAttributesForUserSearch',
|
|
|
|
'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch',
|
|
|
|
'ldap_expert_username_attr' => 'ldapExpertUsernameAttr',
|
|
|
|
'ldap_expert_uuid_user_attr' => 'ldapExpertUUIDUserAttr',
|
|
|
|
'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr',
|
|
|
|
'has_memberof_filter_support' => 'hasMemberOfFilterSupport',
|
2015-06-03 18:37:36 +03:00
|
|
|
'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',
|
2020-10-05 16:12:57 +03:00
|
|
|
'last_jpegPhoto_lookup' => 'lastJpegPhotoLookup',
|
|
|
|
'ldap_nested_groups' => 'ldapNestedGroups',
|
|
|
|
'ldap_paging_size' => 'ldapPagingSize',
|
|
|
|
'ldap_turn_on_pwd_change' => 'turnOnPasswordChange',
|
|
|
|
'ldap_experienced_admin' => 'ldapExperiencedAdmin',
|
|
|
|
'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL',
|
|
|
|
'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN',
|
|
|
|
'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute',
|
2020-06-24 14:09:15 +03:00
|
|
|
'ldap_matching_rule_in_chain_state' => 'ldapMatchingRuleInChainState',
|
2020-10-05 16:12:57 +03:00
|
|
|
'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig
|
2020-03-26 11:30:18 +03:00
|
|
|
];
|
2013-09-27 00:31:57 +04:00
|
|
|
return $array;
|
|
|
|
}
|
|
|
|
|
2018-07-04 01:10:43 +03:00
|
|
|
/**
|
|
|
|
* @param string $rule
|
|
|
|
* @return array
|
|
|
|
* @throws \RuntimeException
|
|
|
|
*/
|
|
|
|
public function resolveRule($rule) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($rule === 'avatar') {
|
2018-07-04 01:10:43 +03:00
|
|
|
return $this->getAvatarAttributes();
|
|
|
|
}
|
|
|
|
throw new \RuntimeException('Invalid rule');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAvatarAttributes() {
|
|
|
|
$value = $this->ldapUserAvatarRule ?: self::AVATAR_PREFIX_DEFAULT;
|
|
|
|
$defaultAttributes = ['jpegphoto', 'thumbnailphoto'];
|
|
|
|
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($value === self::AVATAR_PREFIX_NONE) {
|
2018-07-04 01:10:43 +03:00
|
|
|
return [];
|
|
|
|
}
|
2020-04-10 15:19:56 +03:00
|
|
|
if (strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) {
|
2018-07-04 01:10:43 +03:00
|
|
|
$attribute = trim(substr($value, strlen(self::AVATAR_PREFIX_DATA_ATTRIBUTE)));
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($attribute === '') {
|
2018-07-04 01:10:43 +03:00
|
|
|
return $defaultAttributes;
|
|
|
|
}
|
2018-07-05 12:29:19 +03:00
|
|
|
return [strtolower($attribute)];
|
2018-07-04 01:10:43 +03:00
|
|
|
}
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($value !== self::AVATAR_PREFIX_DEFAULT) {
|
2018-07-04 01:10:43 +03:00
|
|
|
\OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
|
|
|
|
}
|
|
|
|
return $defaultAttributes;
|
|
|
|
}
|
2014-05-13 15:29:25 +04:00
|
|
|
}
|