Merge branch 'master' into dist/envole/7/master

This commit is contained in:
Arnaud Fornerot 2022-05-10 09:31:05 +02:00
commit 88f44d5ed6
2 changed files with 55 additions and 24 deletions

View File

@ -102,6 +102,17 @@ class SynchroUsersCommand extends Command
$ldapusers = array(); $ldapusers = array();
$ldapmails = 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") { if($ldap_model=="scribe") {
$this->writeln(''); $this->writeln('');
@ -147,6 +158,32 @@ class SynchroUsersCommand extends Command
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); 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 - ".$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 - ".$result["cn"];
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,false);
}
// Options // Options
$this->writeln(''); $this->writeln('');
$this->writeln('== OPTIONS =========================================='); $this->writeln('== OPTIONS ==========================================');
@ -379,15 +416,6 @@ class SynchroUsersCommand extends Command
$this->writeln('== GROUPS ============================================'); $this->writeln('== GROUPS ============================================');
$groups=$this->em->getRepository("App:Group")->findAll(); $groups=$this->em->getRepository("App:Group")->findAll();
foreach($groups as $group) { 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(!$group->getLdapfilter()) continue;
if(!in_array($group->getId(),$this->ldapgroups)) { if(!in_array($group->getId(),$this->ldapgroups)) {
@ -416,10 +444,23 @@ class SynchroUsersCommand extends Command
$this->writeln('== SYNCHONISATION NINEGATE TO BUNDLE ================'); $this->writeln('== SYNCHONISATION NINEGATE TO BUNDLE ================');
$this->writeln('====================================================='); $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"); $appmasterurl = $this->container->getParameter("appMasterurl");
$appmasterkey = $this->container->getParameter("appMasterkey"); $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) { if(stripos($appmasterurl,"/")===0) {
$url="http://".$this->container->getParameter("appWeburl").$appmasterurl; $url="http://".$this->container->getParameter("appWeburl").$appmasterurl;
} }
@ -441,7 +482,6 @@ class SynchroUsersCommand extends Command
} }
catch (\Exception $e) { catch (\Exception $e) {
// On tente avec le proxy s'il y en a un // On tente avec le proxy s'il y en a un
echo "pouet";
$proxyUse = $this->container->getParameter("proxyUse"); $proxyUse = $this->container->getParameter("proxyUse");
if($proxyUse) { if($proxyUse) {
$proxyHost = $this->container->getParameter("proxyHost"); $proxyHost = $this->container->getParameter("proxyHost");
@ -452,11 +492,11 @@ class SynchroUsersCommand extends Command
$response = \Unirest\Request::post($url.'/rest/login/'.$appmasterkey,$headers,$query); $response = \Unirest\Request::post($url.'/rest/login/'.$appmasterkey,$headers,$query);
} }
catch (\Exception $e) { catch (\Exception $e) {
die("Erreur de communication API with proxy $url = ".$e->getMessage()."\n"); die("Erreur de communication API = ".$e->getMessage()."\n");
} }
} }
else { 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 ============================================'); $this->writeln('== GROUPS ============================================');
$groups=$this->em->getRepository("App:Group")->findAll(); $groups=$this->em->getRepository("App:Group")->findAll();
foreach($groups as $group) { 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(!$group->getIdexternal()) continue;
if(!in_array($group->getIdexternal(),$lstgroups)) { if(!in_array($group->getIdexternal(),$lstgroups)) {

View File

@ -76,8 +76,8 @@ LDAP_USERNAME=uid
LDAP_FIRSTNAME=givenname LDAP_FIRSTNAME=givenname
LDAP_LASTNAME=sn LDAP_LASTNAME=sn
LDAP_EMAIL=mail LDAP_EMAIL=mail
LDAP_FILTERGROUP=(cn=*) LDAP_FILTERGROUP='(&(ObjectClass=posixGroup)(cn=*))'
LDAP_FILTERUSER=(uid=*) LDAP_FILTERUSER='(&(ObjectClass=person)(uid=*))'
%else %else
LDAP_USERNAME=%%ninesurvey_ldapuid LDAP_USERNAME=%%ninesurvey_ldapuid
LDAP_FIRSTNAME=%%ninesurvey_ldapfirstname LDAP_FIRSTNAME=%%ninesurvey_ldapfirstname