synchro modif

This commit is contained in:
Arnaud Fornerot 2022-05-09 15:25:57 +02:00
parent d24cb0f5e3
commit 27f797dac3
2 changed files with 53 additions and 21 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 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 // 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,12 +444,25 @@ 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'urol de communication // Généraltion de l'urol de communication
if(stripos($appmasterurl,"/")===0) { if(stripos($appmasterurl,"/")===0) {
$url="https://".$this->container->getParameter("appWeburl").$appmasterurl; $url="http://".$this->container->getParameter("appWeburl").$appmasterurl;
} }
else else
$url=$appmasterurl; $url=$appmasterurl;
@ -623,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=%%nineskeletor_ldapuid LDAP_USERNAME=%%nineskeletor_ldapuid
LDAP_FIRSTNAME=%%nineskeletor_ldapfirstname LDAP_FIRSTNAME=%%nineskeletor_ldapfirstname