gestion de la deconnexion ldap

This commit is contained in:
afornerot 2021-02-01 10:58:48 +01:00
parent 70d1ccd220
commit 5ef2a98b51
2 changed files with 24 additions and 7 deletions

View File

@ -45,7 +45,7 @@ class ScribeToNinegateCommand extends Command
$this->host = $input->getArgument('host');
$this->port = 389;
$this->pwd = $input->getArgument('pwd');
$this->user = "cn=admin,o=gouv,c=fr";
$this->user = "cn=reader,o=gouv,c=fr";
$ldap_basedn = $this->container->getParameter('ldap_basedn');
$ldap_username = $this->container->getParameter('ldap_username');
@ -105,9 +105,6 @@ class ScribeToNinegateCommand extends Command
$this->writelnred('PURGE DES BLOG');
$this->purge('CadolesPortalBundle:Blog');
$this->writelnred('PURGE DES PAGES');
$this->purge('CadolesPortalBundle:Page');
$this->writelnred('PURGE DES PROJECT');
$this->purge('CadolesPortalBundle:Project');
@ -126,13 +123,14 @@ class ScribeToNinegateCommand extends Command
$this->writelnred('PURGE DES NIVEAU 01');
$this->purge('CadolesCoreBundle:Niveau01');
$this->writelnred('PURGE DES PAGES');
$this->purge('CadolesPortalBundle:Page');
$this->writelnred('PURGE DES ICONES');
$this->purge('CadolesPortalBundle:Icon');
$this->writeln('');
$this->writelnred('');
$this->writelnred('== INIT DATA');
$command = $this->getApplication()->find("Core:InitData");
@ -253,6 +251,20 @@ class ScribeToNinegateCommand extends Command
}
private function purge($entityname) {
// Si on purge les pages il faut d'abord purger les pages qui ne sont pas pagetemplate
if($entityname=="CadolesPortalBundle:Page") {
$qb=$this->em->createQueryBuilder();
$entitys = $qb->select('t')
->from($entityname,'t')
->where($qb->expr()->isNotNull('t.page'))
->getQuery()
->getResult();
foreach ($entitys as $entity) {
$this->em->remove($entity);
}
$this->em->flush();
}
$entitys=$this->em->getRepository($entityname)->findAll();
foreach ($entitys as $entity) {
$this->em->remove($entity);

View File

@ -45,7 +45,12 @@ class ldapService
}
public function connect() {
// Si on est déjà co = on rebind pour gérer le cas d'un timeout de connection
if($this->connection){
if(!ldap_bind($this->connection, $this->user, $this->password)){
$this->disconnect();
}
}
if($this->connection){
return $this->connection;