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

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

View File

@ -87,7 +87,11 @@
<variable type='oui/non' name='ninegate_syncldap' description="Synchroniser Ninegate vers votre Annuaire CadolesLDAP"><value>non</value></variable> <variable type='oui/non' name='ninegate_syncldap' description="Synchroniser Ninegate vers votre Annuaire CadolesLDAP"><value>non</value></variable>
<variable type='string' name='ninegate_ldaptemplate' description="Modèle d'annuaire"><value>scribe</value></variable> <variable type='string' name='ninegate_ldaptemplate' description="Modèle d'annuaire"><value>scribe</value></variable>
<variable type='oui/non' name='ninegate_scribegroup' description="Considérer les classes/options comme des groupes de travail"><value>oui</value></variable> <variable type='oui/non' name='ninegate_scribegroup' description="Considérer les classes/options comme des groupes de travail"><value>oui</value></variable>
<variable type='oui/non' name='ninegate_scribemaster' description="Placer les professeurs comme manager des groupes classes/options"><value>oui</value></variable> <variable type='string' name='ninegate_scribemaster' description="Placer les professeurs comme manager des groupes classes/options"><value>oui</value></variable>
<variable type='string' name='ninegate_openldapreqniveau01' description="Lors de l'initalisation de Ninegate requete LDAP utilisateur de votre premier Niveau01" mandatory='True'><value>(uid=*)</value></variable>
<variable type='oui/non' name='ninegate_openldapsynchrogroup' description="Générer automatiquement les groupes en fonction de votre annuaire"><value>oui</value></variable>
<variable type='string' name='ninegate_openldapreqgroup' description="Générer automatiquement les groupes en fonction de votre annuaire" mandatory='True'><value>(objectClass=posixGroup)</value></variable>
<variable type='string' name='ninegate_pwdadmin' description="Mot de passe du compte admin durant l'instance (idem valeur Cadoles ldap)" mandatory='True'><value></value></variable> <variable type='string' name='ninegate_pwdadmin' description="Mot de passe du compte admin durant l'instance (idem valeur Cadoles ldap)" mandatory='True'><value></value></variable>
<variable type='string' name='ninegate_organization' description="Nom de l'organisation principale (idem valeur Cadoles ldap)" mandatory='True'><value></value></variable> <variable type='string' name='ninegate_organization' description="Nom de l'organisation principale (idem valeur Cadoles ldap)" mandatory='True'><value></value></variable>
@ -428,6 +432,9 @@
<target type='variable'>ninegate_ldaptemplate</target> <target type='variable'>ninegate_ldaptemplate</target>
<target type='variable'>ninegate_scribegroup</target> <target type='variable'>ninegate_scribegroup</target>
<target type='variable'>ninegate_scribemaster</target> <target type='variable'>ninegate_scribemaster</target>
<target type='variable'>ninegate_openldapreqniveau01</target>
<target type='variable'>ninegate_openldapsynchrogroup</target>
<target type='variable'>ninegate_openldapreqgroup</target>
<target type='variable'>ninegate_pwdadmin</target> <target type='variable'>ninegate_pwdadmin</target>
<target type='variable'>ninegate_organization</target> <target type='variable'>ninegate_organization</target>
@ -604,7 +611,21 @@
<target type='variable'>ninegate_scribemaster</target> <target type='variable'>ninegate_scribemaster</target>
</condition> </condition>
<!-- AFFICHAGE EN FONCTION DU MODE OPEN -->
<condition name='hidden_if_not_in' source='ninegate_ldaptemplate'>
<param>open</param>
<target type='variable'>ninegate_openldapreqniveau01</target>
<target type='variable'>ninegate_openldapsynchrogroup</target>
<target type='variable'>ninegate_openldapreqgroup</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU MODULE PORTAL -->
<condition name='hidden_if_in' source='ninegate_openldapsynchrogroup'>
<param>non</param>
<target type='variable'>ninegate_openldapreqgroup</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU MODULE PORTAL --> <!-- AFFICHAGE EN FONCTION DU MODULE PORTAL -->
<condition name='hidden_if_in' source='ninegate_activate_portal'> <condition name='hidden_if_in' source='ninegate_activate_portal'>

View File

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

View File

@ -174,6 +174,22 @@ class SynchroCommand extends Command
if(!$simulate) $this->addmodGroup($label,$ldapfilter,$scribe_group); 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('');
$this->writeln('== USERS ============================================'); $this->writeln('== USERS ============================================');
@ -760,6 +776,12 @@ class SynchroCommand extends Command
protected function addmodGroup($label,$ldapfilter,$fgcanshare) { protected function addmodGroup($label,$ldapfilter,$fgcanshare) {
$portal_activate = $this->container->getParameter('portal_activate'); $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)); $group=$this->em->getRepository('CadolesCoreBundle:Group')->findOneBy(array('fgtemplate' => true, 'label' => $label));
if(!$group) { if(!$group) {
$group=new Group(); $group=new Group();

View File

@ -203,6 +203,23 @@ parameters:
scribe_master: false scribe_master: false
%end if %end if
%if %%getVar("ninegate_ldaptemplate", 'non') == "open"
openldapreqniveau01: %%ninegate_openldapreqniveau01
%if %%getVar("ninegate_openldapsynchrogroup", 'non') == "oui"
openldapsynchrogroup: true
openldapreqgroup: %%ninegate_openldapreqgroup
%else
openldapsynchrogroup: false
openldapreqgroup:
%end if
%else
openldapreqniveau01:
openldapsynchrogroup: false
openldapreqgroup:
%end if
# Activation Widget # Activation Widget
%if %%getVar("ninegate_activate_widadminer", 'non') == "oui" %if %%getVar("ninegate_activate_widadminer", 'non') == "oui"