From: hickert Date: Fri, 10 Mar 2006 09:41:29 +0000 (+0000) Subject: Added switch to allow, groups with same name in different subtrees or not X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e086ec69e769370ee1d612c631a2d5b89b947d73;p=gosa.git Added switch to allow, groups with same name in different subtrees or not git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2838 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/class_groupGeneric.inc b/plugins/admin/groups/class_groupGeneric.inc index 4e235a6c8..f59768a26 100644 --- a/plugins/admin/groups/class_groupGeneric.inc +++ b/plugins/admin/groups/class_groupGeneric.inc @@ -30,6 +30,7 @@ class group extends plugin var $saved_gidNumber= ""; var $oldgroupType= ""; var $orig_dn= ""; + var $orig_cn= ""; var $has_mailAccount= FALSE; var $group_dialog= FALSE; var $nagios_group =FALSE; @@ -37,6 +38,8 @@ class group extends plugin var $dialog; var $OnlyShowFirstEntries =200; + var $allowGroupsWithSameNameInOtherSubtrees = true; + /* attribute list for save action */ var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID"); var $objectclasses= array("top", "posixGroup"); @@ -48,6 +51,7 @@ class group extends plugin /* Load attributes depending on the samba version */ $this->samba3= ($config->current['SAMBAVERSION'] == 3); $this->orig_dn= $dn; + $this->orig_cn= $this->cn; /* Get member list */ if (isset($this->attrs['memberUid'][0])){ @@ -721,26 +725,42 @@ class group extends plugin $message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed."); } - /* Check for used 'cn' */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn")); - if ($ldap->count() != 0){ - /* New entry? */ - if ($this->dn == 'new'){ - $message[]= _("Value specified as 'Name' is already used."); + if($this->allowGroupsWithSameNameInOtherSubtrees == true){ + + /* Check for used 'cn' */ + $ldap= $this->config->get_ldap_link(); + if(($this->cn != $this->orig_cn) || ($this->orig_dn == "new")){ + $ldap->cd("ou=groups,".$this->base); + $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))","ou=groups,".$this->base,array("cn")); + if ($ldap->count() != 0){ + $message[]= _("Value specified as 'Name' is already used."); + } } - - /* Moved? */ - elseif ($new_dn != $this->orig_dn){ - $ldap->fetch(); - if ($ldap->getDN() != $this->orig_dn){ + + }else{ + + /* Check for used 'cn' */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn")); + if ($ldap->count() != 0){ + + /* New entry? */ + if ($this->dn == 'new'){ $message[]= _("Value specified as 'Name' is already used."); } + + /* Moved? */ + elseif ($new_dn != $this->orig_dn){ + $ldap->fetch(); + if ($ldap->getDN() != $this->orig_dn){ + $message[]= _("Value specified as 'Name' is already used."); + } + } } } - + /* Check ID */ if ($this->force_gid == "1"){ if (!is_id($this->gidNumber)){