Skip to content
Snippets Groups Projects
Commit bae954a7 authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

LDAP: only check once for name conflicts on update. Set a value on install as well

parent 79223380
No related branches found
No related tags found
No related merge requests found
<?php
$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet');
if($state == 'doSet'){
OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
}
...@@ -12,22 +12,25 @@ if(!is_null($pw)) { ...@@ -12,22 +12,25 @@ if(!is_null($pw)) {
//detect if we can switch on naming guidelines. We won't do it on conflicts. //detect if we can switch on naming guidelines. We won't do it on conflicts.
//it's a bit spaghetti, but hey. //it's a bit spaghetti, but hey.
$sqlCleanMap = 'DELETE FROM *PREFIX*ldap_user_mapping'; $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doCheck');
if($state == 'doCheck'){
$sqlCleanMap = 'DELETE FROM *PREFIX*ldap_user_mapping';
require_once(OC::$APPSROOT.'/apps/user_ldap/lib_ldap.php'); require_once(OC::$APPSROOT.'/apps/user_ldap/lib_ldap.php');
require_once(OC::$APPSROOT.'/apps/user_ldap/user_ldap.php'); require_once(OC::$APPSROOT.'/apps/user_ldap/user_ldap.php');
OCP\Config::setSystemValue('ldapIgnoreNamingRules', true);
$LDAP_USER = new OC_USER_LDAP();
$users_old = $LDAP_USER->getUsers();
$query = OCP\DB::prepare($sqlCleanMap);
$query->execute();
OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
OC_LDAP::init(true);
$users_new = $LDAP_USER->getUsers();
$query = OCP\DB::prepare($sqlCleanMap);
$query->execute();
if($users_old !== $users_new) {
//we don't need to check Groups, because they were not supported in 3'
OCP\Config::setSystemValue('ldapIgnoreNamingRules', true); OCP\Config::setSystemValue('ldapIgnoreNamingRules', true);
$LDAP_USER = new OC_USER_LDAP();
$users_old = $LDAP_USER->getUsers();
$query = OCP\DB::prepare($sqlCleanMap);
$query->execute();
OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
OC_LDAP::init(true);
$users_new = $LDAP_USER->getUsers();
$query = OCP\DB::prepare($sqlCleanMap);
$query->execute();
if($users_old !== $users_new) {
//we don't need to check Groups, because they were not supported in 3'
OCP\Config::setSystemValue('ldapIgnoreNamingRules', true);
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment