From ef0ba6ef25c7d5a9cb5753c6669a5e6a6cba4298 Mon Sep 17 00:00:00 2001 From: afornerot Date: Wed, 24 Feb 2021 10:54:13 +0100 Subject: [PATCH] prise en compte attribut member pour AD --- .../src/Cadoles/CoreBundle/Command/SynchroCommand.php | 10 ++++++++++ .../src/Cadoles/CoreBundle/Service/ldapService.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php index dd1e3b31..1ffb91c6 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php @@ -79,6 +79,7 @@ class SynchroCommand extends Command $ldap_member = strtolower($this->container->getParameter('ldap_member')); $scribe_group = strtolower($this->container->getParameter('scribe_group')); + $ldap_type = $this->container->getParameter('ldap_type'); $ldap_template = $this->container->getParameter('ldap_template'); $ldap_usersadmin = $this->container->getParameter('ldap_usersadmin'); $scribe_master = strtolower($this->container->getParameter('scribe_master')); @@ -633,10 +634,13 @@ class SynchroCommand extends Command $dn=$this->ldap->getNiveau01DN($data->getLabel()); $attrs["memberuid"]=array(); $attrs["cadolesMember"]=array(); + if($ldap_type=="AD") $attrs["member"]=array(); foreach($data->getUsers() as $userniveau01) { array_push($attrs["memberuid"],$userniveau01->getUsername()); array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01)); + if($ldap_type=="AD") array_push($attrs["member"],$this->ldap->getUserDN($userniveau01)); + $this->writeln(' > '.$userniveau01->getUsername()); } if(!$simulate) $this->ldap->ldapModify($dn, $attrs); @@ -664,10 +668,13 @@ class SynchroCommand extends Command $dn=$this->ldap->getNiveau02DN($data->getLabel()); $attrs["memberuid"]=array(); $attrs["cadolesMember"]=array(); + if($ldap_type=="AD") $attrs["member"]=array(); foreach($data->getUsers() as $userniveau01) { array_push($attrs["memberuid"],$userniveau01->getUsername()); array_push($attrs["cadolesMember"],$this->ldap->getUserDN($userniveau01)); + if($ldap_type=="AD") array_push($attrs["member"],$this->ldap->getUserDN($userniveau01)); + $this->writeln(' > '.$userniveau01->getUsername()); } if(!$simulate) $this->ldap->ldapModify($dn, $attrs); @@ -696,11 +703,14 @@ class SynchroCommand extends Command $dn=$this->ldap->getGroupDN($data->getLabel()); $attrs["memberuid"]=array(); $attrs["cadolesMember"]=array(); + if($ldap_type=="AD") $attrs['member']=array(); foreach($data->getUsers() as $usergroupe) { if(!in_array($usergroupe->getUser()->getUsername(), $attrs["memberuid"])) { array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername()); 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()); } else { diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Service/ldapService.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Service/ldapService.php index 6516c0cb..3bcc1d45 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Service/ldapService.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Service/ldapService.php @@ -241,6 +241,7 @@ class ldapService $dn = $this->getNiveau01DN($result["cn"]); $entry['memberuid'] = $user->getUsername(); $entry['cadolesMember'] = $this->getUserDN($user); + if($this->type=="AD") $entry['member'] = $this->getUserDN($user); $result = ldap_mod_del($connection, $dn, $entry); if(!$result) $this->ldapError(); @@ -257,6 +258,7 @@ class ldapService $dn = $this->getNiveau01DN($user->getNiveau01()->getLabel()); $entry['memberuid'] = $user->getUsername(); $entry['cadolesMember'] = $this->getUserDN($user); + if($this->type=="AD") $entry['member'] = $this->getUserDN($user); $result = ldap_mod_add($connection, $dn, $entry); if(!$result) $this->ldapError(); @@ -273,6 +275,8 @@ class ldapService $dn = $this->getNiveau02DN($result["cn"]); $entry['memberuid'] = $user->getUsername(); $entry['cadolesMember'] = $this->getUserDN($user); + if($this->type=="AD") $entry['member'] = $this->getUserDN($user); + $result = ldap_mod_del($connection, $dn, $entry); if(!$result) $this->ldapError(); } @@ -289,6 +293,8 @@ class ldapService $dn = $this->getNiveau02DN($user->getNiveau02()->getLabel()); $entry['memberuid'] = $user->getUsername(); $entry['cadolesMember'] = $this->getUserDN($user); + if($this->type=="AD") $entry['member'] = $this->getUserDN($user); + $result = ldap_mod_add($connection, $dn, $entry); if(!$result) $this->ldapError(); } @@ -652,6 +658,8 @@ class ldapService $dn = $this->getGroupDN($usergroup->getGroup()->getLabel()); $entry['memberuid'] = $usergroup->getUser()->getUsername(); $entry['cadolesMember'] = $this->getUserDN($usergroup->getUser()); + if($this->type=="AD") $entry['member'] = $this->getUserDN($usergroup->getUser()); + $result = ldap_mod_add($connection, $dn, $entry); if(!$result) $this->ldapError(); } @@ -673,6 +681,8 @@ class ldapService $dn = $this->getGroupDN($usergroup->getGroup()->getLabel()); $entry['memberuid'] = $usergroup->getUser()->getUsername(); $entry['cadolesMember'] = $this->getUserDN($usergroup->getUser()); + if($this->type=="AD") $entry['member'] = $this->getUserDN($usergroup->getUser()); + $result = ldap_mod_del($connection, $dn, $entry); if(!$result) $this->ldapError(); }