This commit is contained in:
afornerot 2019-06-24 11:48:49 +02:00
parent f2b050a88d
commit 75d979fa09
2 changed files with 10 additions and 5 deletions

View File

@ -160,11 +160,18 @@ class SynchroCommand extends Command
} }
} }
else { else {
$toadmin=false;
if(in_array($result[$ldap_username],$ldap_usersadmin)&&$user->getRole()!="ROLE_ADMIN")
$toadmin=true;
if($user->getLastname()!=$result[$ldap_username]||$user->getFirstname()!=$result[$ldap_firstname]||$user->getEmail()!=$result[$ldap_email]||$toadmin) {
$this->writeln(" - Modification dans Bundle >> ".$result[$ldap_username]); $this->writeln(" - Modification dans Bundle >> ".$result[$ldap_username]);
if(!$simulate) $this->modUser($user[0],$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin); if(!$simulate) $this->modUser($user[0],$result[$ldap_username],$result[$ldap_firstname],$result[$ldap_lastname],$result[$ldap_email],$ldap_usersadmin);
} }
} }
} }
}
$this->em->flush();
$this->writeln(''); $this->writeln('');
$this->writeln('== USERS GROUP ======================================'); $this->writeln('== USERS GROUP ======================================');
@ -747,7 +754,6 @@ class SynchroCommand extends Command
$user->setRole("ROLE_USER"); $user->setRole("ROLE_USER");
$this->em->persist($user); $this->em->persist($user);
$this->em->flush();
} }
protected function modUser($user,$username,$firstname,$lastname,$email,$usersadmin) { protected function modUser($user,$username,$firstname,$lastname,$email,$usersadmin) {
@ -759,7 +765,6 @@ class SynchroCommand extends Command
$user->setRole("ROLE_ADMIN"); $user->setRole("ROLE_ADMIN");
$this->em->persist($user); $this->em->persist($user);
$this->em->flush();
} }
} }

View File

@ -52,7 +52,7 @@ class ldapService
public function search($filter, $attributes = array(), $subBranch = '') { public function search($filter, $attributes = array(), $subBranch = '') {
$connection = $this->connect(); $connection = $this->connect();
$branch = ($subBranch ? $subBranch : $this->baseDN); $branch = ($subBranch ? $subBranch : $this->baseDN);
$result = ldap_search($connection, $branch, $filter, $attributes); $result = ldap_search($connection, $branch, $filter, $attributes,0,0,0);
if(!$result) { if(!$result) {
$this->ldapError(); $this->ldapError();
} }