prise en compte attribut member pour AD

This commit is contained in:
afornerot 2021-02-24 10:54:13 +01:00
parent d1a3187cba
commit ef0ba6ef25
2 changed files with 20 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class SynchroCommand extends Command
$ldap_member = strtolower($this->container->getParameter('ldap_member')); $ldap_member = strtolower($this->container->getParameter('ldap_member'));
$scribe_group = strtolower($this->container->getParameter('scribe_group')); $scribe_group = strtolower($this->container->getParameter('scribe_group'));
$ldap_type = $this->container->getParameter('ldap_type');
$ldap_template = $this->container->getParameter('ldap_template'); $ldap_template = $this->container->getParameter('ldap_template');
$ldap_usersadmin = $this->container->getParameter('ldap_usersadmin'); $ldap_usersadmin = $this->container->getParameter('ldap_usersadmin');
$scribe_master = strtolower($this->container->getParameter('scribe_master')); $scribe_master = strtolower($this->container->getParameter('scribe_master'));
@ -633,10 +634,13 @@ class SynchroCommand extends Command
$dn=$this->ldap->getNiveau01DN($data->getLabel()); $dn=$this->ldap->getNiveau01DN($data->getLabel());
$attrs["memberuid"]=array(); $attrs["memberuid"]=array();
$attrs["cadolesMember"]=array(); $attrs["cadolesMember"]=array();
if($ldap_type=="AD") $attrs["member"]=array();
foreach($data->getUsers() as $userniveau01) { foreach($data->getUsers() as $userniveau01) {
array_push($attrs["memberuid"],$userniveau01->getUsername()); array_push($attrs["memberuid"],$userniveau01->getUsername());
array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01)); array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01));
if($ldap_type=="AD") array_push($attrs["member"],$this->ldap->getUserDN($userniveau01));
$this->writeln(' > '.$userniveau01->getUsername()); $this->writeln(' > '.$userniveau01->getUsername());
} }
if(!$simulate) $this->ldap->ldapModify($dn, $attrs); if(!$simulate) $this->ldap->ldapModify($dn, $attrs);
@ -664,10 +668,13 @@ class SynchroCommand extends Command
$dn=$this->ldap->getNiveau02DN($data->getLabel()); $dn=$this->ldap->getNiveau02DN($data->getLabel());
$attrs["memberuid"]=array(); $attrs["memberuid"]=array();
$attrs["cadolesMember"]=array(); $attrs["cadolesMember"]=array();
if($ldap_type=="AD") $attrs["member"]=array();
foreach($data->getUsers() as $userniveau01) { foreach($data->getUsers() as $userniveau01) {
array_push($attrs["memberuid"],$userniveau01->getUsername()); array_push($attrs["memberuid"],$userniveau01->getUsername());
array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01)); array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01));
if($ldap_type=="AD") array_push($attrs["member"],$this->ldap->getUserDN($userniveau01));
$this->writeln(' > '.$userniveau01->getUsername()); $this->writeln(' > '.$userniveau01->getUsername());
} }
if(!$simulate) $this->ldap->ldapModify($dn, $attrs); if(!$simulate) $this->ldap->ldapModify($dn, $attrs);
@ -696,11 +703,14 @@ class SynchroCommand extends Command
$dn=$this->ldap->getGroupDN($data->getLabel()); $dn=$this->ldap->getGroupDN($data->getLabel());
$attrs["memberuid"]=array(); $attrs["memberuid"]=array();
$attrs["cadolesMember"]=array(); $attrs["cadolesMember"]=array();
if($ldap_type=="AD") $attrs['member']=array();
foreach($data->getUsers() as $usergroupe) { foreach($data->getUsers() as $usergroupe) {
if(!in_array($usergroupe->getUser()->getUsername(), $attrs["memberuid"])) { if(!in_array($usergroupe->getUser()->getUsername(), $attrs["memberuid"])) {
array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername()); array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername());
array_push($attrs["cadolesMember"],$this->ldap->getUserDN($usergroupe->getUser())); array_push($attrs["cadolesMember"],$this->ldap->getUserDN($usergroupe->getUser()));
if($ldap_type=="AD") array_push($attrs["member"],$this->ldap->getUserDN($usergroupe->getUser()));
$this->writeln(' > '.$usergroupe->getUser()->getUsername()); $this->writeln(' > '.$usergroupe->getUser()->getUsername());
} }
else { else {

View File

@ -241,6 +241,7 @@ class ldapService
$dn = $this->getNiveau01DN($result["cn"]); $dn = $this->getNiveau01DN($result["cn"]);
$entry['memberuid'] = $user->getUsername(); $entry['memberuid'] = $user->getUsername();
$entry['cadolesMember'] = $this->getUserDN($user); $entry['cadolesMember'] = $this->getUserDN($user);
if($this->type=="AD") $entry['member'] = $this->getUserDN($user);
$result = ldap_mod_del($connection, $dn, $entry); $result = ldap_mod_del($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
@ -257,6 +258,7 @@ class ldapService
$dn = $this->getNiveau01DN($user->getNiveau01()->getLabel()); $dn = $this->getNiveau01DN($user->getNiveau01()->getLabel());
$entry['memberuid'] = $user->getUsername(); $entry['memberuid'] = $user->getUsername();
$entry['cadolesMember'] = $this->getUserDN($user); $entry['cadolesMember'] = $this->getUserDN($user);
if($this->type=="AD") $entry['member'] = $this->getUserDN($user);
$result = ldap_mod_add($connection, $dn, $entry); $result = ldap_mod_add($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
@ -273,6 +275,8 @@ class ldapService
$dn = $this->getNiveau02DN($result["cn"]); $dn = $this->getNiveau02DN($result["cn"]);
$entry['memberuid'] = $user->getUsername(); $entry['memberuid'] = $user->getUsername();
$entry['cadolesMember'] = $this->getUserDN($user); $entry['cadolesMember'] = $this->getUserDN($user);
if($this->type=="AD") $entry['member'] = $this->getUserDN($user);
$result = ldap_mod_del($connection, $dn, $entry); $result = ldap_mod_del($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
} }
@ -289,6 +293,8 @@ class ldapService
$dn = $this->getNiveau02DN($user->getNiveau02()->getLabel()); $dn = $this->getNiveau02DN($user->getNiveau02()->getLabel());
$entry['memberuid'] = $user->getUsername(); $entry['memberuid'] = $user->getUsername();
$entry['cadolesMember'] = $this->getUserDN($user); $entry['cadolesMember'] = $this->getUserDN($user);
if($this->type=="AD") $entry['member'] = $this->getUserDN($user);
$result = ldap_mod_add($connection, $dn, $entry); $result = ldap_mod_add($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
} }
@ -652,6 +658,8 @@ class ldapService
$dn = $this->getGroupDN($usergroup->getGroup()->getLabel()); $dn = $this->getGroupDN($usergroup->getGroup()->getLabel());
$entry['memberuid'] = $usergroup->getUser()->getUsername(); $entry['memberuid'] = $usergroup->getUser()->getUsername();
$entry['cadolesMember'] = $this->getUserDN($usergroup->getUser()); $entry['cadolesMember'] = $this->getUserDN($usergroup->getUser());
if($this->type=="AD") $entry['member'] = $this->getUserDN($usergroup->getUser());
$result = ldap_mod_add($connection, $dn, $entry); $result = ldap_mod_add($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
} }
@ -673,6 +681,8 @@ class ldapService
$dn = $this->getGroupDN($usergroup->getGroup()->getLabel()); $dn = $this->getGroupDN($usergroup->getGroup()->getLabel());
$entry['memberuid'] = $usergroup->getUser()->getUsername(); $entry['memberuid'] = $usergroup->getUser()->getUsername();
$entry['cadolesMember'] = $this->getUserDN($usergroup->getUser()); $entry['cadolesMember'] = $this->getUserDN($usergroup->getUser());
if($this->type=="AD") $entry['member'] = $this->getUserDN($usergroup->getUser());
$result = ldap_mod_del($connection, $dn, $entry); $result = ldap_mod_del($connection, $dn, $entry);
if(!$result) $this->ldapError(); if(!$result) $this->ldapError();
} }