From 3f839ba8d084683cff138573c52ba3810a6bd1a8 Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Mon, 9 May 2022 15:35:19 +0200 Subject: [PATCH 1/3] synchro modif --- .../src/Command/SynchroUsersCommand.php | 75 +++++++++++++------ tmpl/ninesurvey-env.local | 4 +- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php b/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php index 6c613b9..bfedf56 100644 --- a/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php +++ b/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php @@ -102,6 +102,17 @@ class SynchroUsersCommand extends Command $ldapusers = array(); $ldapmails = array(); + // Suppression des groupe ninegate + $groups=$this->em->getRepository("App:Group")->findAll(); + foreach($groups as $group) { + if($group->getIdexternal()) { + $this->writeln(" - Suppression dans Bundle >> ".$group->getName()); + if(!$simulate) { + $this->em->remove($group); + $this->em->flush(); + } + } + } if($ldap_model=="scribe") { $this->writeln(''); @@ -147,6 +158,32 @@ class SynchroUsersCommand extends Command if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); } + // Elèves des Classes + $this->writeln(''); + $this->writeln('== ELEVES DES CLASSES =========================================='); + $results = $this->ldap->search("type=Classe", ['cn','description','gidNumber'], $this->ldap_basedn); + foreach($results as $result) { + $cn=$result["cn"]; + $ldapfilter="(&(type=Classe)(cn=$cn))"; + + $label="ELEVES DE LA CLASSE - ".$result["cn"]; + $this->writeln(" - $label"); + if(!$simulate) $this->addmodGroup($label,$ldapfilter,false); + } + + // Professeurs des Classes + $this->writeln(''); + $this->writeln('== PROFESSEURS DES CLASSES =========================================='); + $results = $this->ldap->search("type=Classe", ['cn','description','gidNumber'], $this->ldap_basedn); + foreach($results as $result) { + $cn=$result["cn"]; + $ldapfilter="(|(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))"; + + $label="PROFESSEURS DE LA CLASSE - ".$result["cn"]; + $this->writeln(" - $label"); + if(!$simulate) $this->addmodGroup($label,$ldapfilter,false); + } + // Options $this->writeln(''); $this->writeln('== OPTIONS =========================================='); @@ -379,15 +416,6 @@ class SynchroUsersCommand extends Command $this->writeln('== GROUPS ============================================'); $groups=$this->em->getRepository("App:Group")->findAll(); foreach($groups as $group) { - if($group->getIdexternal()) { - $this->writeln(" - Suppression dans Bundle >> ".$group->getName()); - if(!$simulate) { - $this->em->remove($group); - $this->em->flush(); - - } - } - if(!$group->getLdapfilter()) continue; if(!in_array($group->getId(),$this->ldapgroups)) { @@ -416,10 +444,23 @@ class SynchroUsersCommand extends Command $this->writeln('== SYNCHONISATION NINEGATE TO BUNDLE ================'); $this->writeln('====================================================='); + + // Suppression des groupe annuaire + $groups=$this->em->getRepository("App:Group")->findAll(); + foreach($groups as $group) { + if($group->getLdapfilter()) { + $this->writeln(" - Suppression dans Bundle >> ".$group->getName()); + if(!$simulate) { + $this->em->remove($group); + $this->em->flush(); + } + } + } + $appmasterurl = $this->container->getParameter("appMasterurl"); $appmasterkey = $this->container->getParameter("appMasterkey"); - // Généraltion de l'url de communication + // Généraltion de l'urol de communication if(stripos($appmasterurl,"/")===0) { $url="http://".$this->container->getParameter("appWeburl").$appmasterurl; } @@ -441,7 +482,6 @@ class SynchroUsersCommand extends Command } catch (\Exception $e) { // On tente avec le proxy s'il y en a un - echo "pouet"; $proxyUse = $this->container->getParameter("proxyUse"); if($proxyUse) { $proxyHost = $this->container->getParameter("proxyHost"); @@ -452,11 +492,11 @@ class SynchroUsersCommand extends Command $response = \Unirest\Request::post($url.'/rest/login/'.$appmasterkey,$headers,$query); } catch (\Exception $e) { - die("Erreur de communication API with proxy $url = ".$e->getMessage()."\n"); + die("Erreur de communication API = ".$e->getMessage()."\n"); } } else { - die("Erreur de communication API without proxy $url = ".$e->getMessage()."\n"); + die("Erreur de communication API = ".$e->getMessage()."\n"); } } @@ -624,15 +664,6 @@ class SynchroUsersCommand extends Command $this->writeln('== GROUPS ============================================'); $groups=$this->em->getRepository("App:Group")->findAll(); foreach($groups as $group) { - if($group->getLdapfilter()) { - $this->writeln(" - Suppression dans Bundle >> ".$group->getName()); - if(!$simulate) { - $this->em->remove($group); - $this->em->flush(); - - } - } - if(!$group->getIdexternal()) continue; if(!in_array($group->getIdexternal(),$lstgroups)) { diff --git a/tmpl/ninesurvey-env.local b/tmpl/ninesurvey-env.local index c7f74f2..d39484d 100644 --- a/tmpl/ninesurvey-env.local +++ b/tmpl/ninesurvey-env.local @@ -76,8 +76,8 @@ LDAP_USERNAME=uid LDAP_FIRSTNAME=givenname LDAP_LASTNAME=sn LDAP_EMAIL=mail -LDAP_FILTERGROUP=(cn=*) -LDAP_FILTERUSER=(uid=*) +LDAP_FILTERGROUP=(&(ObjectClass=posixGroup)(cn=*)) +LDAP_FILTERUSER=(&(ObjectClass=person)(uid=*)) %else LDAP_USERNAME=%%ninesurvey_ldapuid LDAP_FIRSTNAME=%%ninesurvey_ldapfirstname From b01e053b5d0815f52f9a4f2f0f27430a0e634eca Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Mon, 9 May 2022 15:57:50 +0200 Subject: [PATCH 2/3] synchro modif --- tmpl/ninesurvey-env.local | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmpl/ninesurvey-env.local b/tmpl/ninesurvey-env.local index d39484d..c2aa529 100644 --- a/tmpl/ninesurvey-env.local +++ b/tmpl/ninesurvey-env.local @@ -76,8 +76,8 @@ LDAP_USERNAME=uid LDAP_FIRSTNAME=givenname LDAP_LASTNAME=sn LDAP_EMAIL=mail -LDAP_FILTERGROUP=(&(ObjectClass=posixGroup)(cn=*)) -LDAP_FILTERUSER=(&(ObjectClass=person)(uid=*)) +LDAP_FILTERGROUP='(&(ObjectClass=posixGroup)(cn=*))' +LDAP_FILTERUSER='(&(ObjectClass=person)(uid=*))' %else LDAP_USERNAME=%%ninesurvey_ldapuid LDAP_FIRSTNAME=%%ninesurvey_ldapfirstname From a4573d977f63f9da6dc5173ddbf31db7f0839c48 Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Tue, 10 May 2022 09:24:44 +0200 Subject: [PATCH 3/3] Synchronisation scribe niveaux + eleves classes + profs classes (ref #34132) --- src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php b/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php index bfedf56..7c2f2d2 100644 --- a/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php +++ b/src/ninesurvey-1.0/src/Command/SynchroUsersCommand.php @@ -166,7 +166,7 @@ class SynchroUsersCommand extends Command $cn=$result["cn"]; $ldapfilter="(&(type=Classe)(cn=$cn))"; - $label="ELEVES DE LA CLASSE - ".$result["cn"]; + $label="ELEVES - ".$result["cn"]; $this->writeln(" - $label"); if(!$simulate) $this->addmodGroup($label,$ldapfilter,false); } @@ -179,7 +179,7 @@ class SynchroUsersCommand extends Command $cn=$result["cn"]; $ldapfilter="(|(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))"; - $label="PROFESSEURS DE LA CLASSE - ".$result["cn"]; + $label="PROFESSEURS - ".$result["cn"]; $this->writeln(" - $label"); if(!$simulate) $this->addmodGroup($label,$ldapfilter,false); }