mise en place d'une auto creation des groupes sur le modele LDAP-Open

This commit is contained in:
2020-09-29 17:18:21 +02:00
parent 93c6a9a1e1
commit 21295df381
4 changed files with 140 additions and 80 deletions

View File

@ -144,7 +144,7 @@ class InitDataCommand extends ContainerAwareCommand
if($ldap_template=="scribe")
$niveau01->setLdapfilter("(&(uid=*)(objectclass=inetOrgPerson)(!(description=Computer)))");
else
$niveau01->setLdapfilter("(uid=*)");
$niveau01->setLdapfilter($this->getContainer()->getParameter('openldapreqniveau01'));
$em->persist($niveau01);
$em->flush();

View File

@ -174,6 +174,22 @@ class SynchroCommand extends Command
if(!$simulate) $this->addmodGroup($label,$ldapfilter,$scribe_group);
}
}
elseif($ldap_template=="open") {
if($this->container->getParameter('openldapsynchrogroup')) {
$this->writeln('');
$this->writeln('== GROUPES ==========================================');
$results = $this->ldap->search($this->container->getParameter('openldapreqgroup'), ['cn','description','gidNumber'], $this->ldap_basedn);
foreach($results as $result) {
$cn=$result["cn"];
$ldapfilter="(&".$this->container->getParameter('openldapreqgroup')."(cn=$cn))";
$label=$result["cn"];
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,false);
}
}
}
$this->writeln('');
$this->writeln('== USERS ============================================');
@ -760,6 +776,12 @@ class SynchroCommand extends Command
protected function addmodGroup($label,$ldapfilter,$fgcanshare) {
$portal_activate = $this->container->getParameter('portal_activate');
$group=$this->em->getRepository('CadolesCoreBundle:Group')->findOneBy(array('fgtemplate' => false, 'label' => $label));
if($group) {
$this->writelnred(" - ".$label." existe déjà comme groupe interne à Ninegate");
return 0;
}
$group=$this->em->getRepository('CadolesCoreBundle:Group')->findOneBy(array('fgtemplate' => true, 'label' => $label));
if(!$group) {
$group=new Group();