2012-05-14 14:58:58 +04:00
|
|
|
<?php
|
|
|
|
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance = \OC::$server->getConfig();
|
|
|
|
|
2012-05-17 21:33:38 +04:00
|
|
|
//detect if we can switch on naming guidelines. We won't do it on conflicts.
|
|
|
|
//it's a bit spaghetti, but hey.
|
2014-12-17 13:12:37 +03:00
|
|
|
$state = $configInstance->getSystemValue('ldapIgnoreNamingRules', 'unset');
|
2013-04-21 00:45:17 +04:00
|
|
|
if($state === 'unset') {
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setSystemValue('ldapIgnoreNamingRules', false);
|
2012-05-28 15:57:45 +04:00
|
|
|
}
|
2012-07-02 22:31:07 +04:00
|
|
|
|
2014-12-17 13:12:37 +03:00
|
|
|
$installedVersion = $configInstance->getAppValue('user_ldap', 'installed_version');
|
2014-05-13 19:47:00 +04:00
|
|
|
$enableRawMode = version_compare($installedVersion, '0.4.1', '<');
|
|
|
|
|
2014-08-21 19:59:13 +04:00
|
|
|
$helper = new \OCA\user_ldap\lib\Helper();
|
|
|
|
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
2013-09-13 21:01:40 +04:00
|
|
|
$ldap = new OCA\user_ldap\lib\LDAP();
|
|
|
|
foreach($configPrefixes as $config) {
|
|
|
|
$connection = new OCA\user_ldap\lib\Connection($ldap, $config);
|
|
|
|
|
2014-12-17 13:12:37 +03:00
|
|
|
$state = $configInstance->getAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_uuid_user_attribute', 'not existing');
|
|
|
|
if($state === 'non existing') {
|
2014-12-17 13:12:37 +03:00
|
|
|
$value = $configInstance->getAppValue(
|
2014-10-07 18:45:22 +04:00
|
|
|
'user_ldap', $config.'ldap_uuid_attribute', '');
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_uuid_user_attribute', $value);
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_uuid_group_attribute', $value);
|
|
|
|
}
|
|
|
|
|
2014-12-17 13:12:37 +03:00
|
|
|
$state = $configInstance->getAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_expert_uuid_user_attr', 'not existing');
|
|
|
|
if($state === 'non existing') {
|
2014-12-17 13:12:37 +03:00
|
|
|
$value = $configInstance->getAppValue(
|
2014-10-07 18:45:22 +04:00
|
|
|
'user_ldap', $config.'ldap_expert_uuid_attr', '');
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_expert_uuid_user_attr', $value);
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setAppValue(
|
2014-05-13 19:47:00 +04:00
|
|
|
'user_ldap', $config.'ldap_expert_uuid_group_attr', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($enableRawMode) {
|
2014-12-17 13:12:37 +03:00
|
|
|
$configInstance->setAppValue('user_ldap', $config.'ldap_user_filter_mode', 1);
|
|
|
|
$configInstance->setAppValue('user_ldap', $config.'ldap_login_filter_mode', 1);
|
|
|
|
$configInstance->setAppValue('user_ldap', $config.'ldap_group_filter_mode', 1);
|
2014-05-13 19:47:00 +04:00
|
|
|
}
|
2013-01-25 01:39:05 +04:00
|
|
|
}
|