From: cajus Date: Tue, 6 Feb 2007 11:09:31 +0000 (+0000) Subject: Added RDN style for users X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6d223a903910138f9478829643ea9890ed130f0b;p=gosa.git Added RDN style for users git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5692 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_tabs.inc b/include/class_tabs.inc index 8e2d42ca4..0808b9abe 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -124,7 +124,6 @@ class tabs $obj->save_object (); $this->by_object[$this->current]= $obj; } - } function gen_tabs() diff --git a/plugins/admin/users/tabs_user.inc b/plugins/admin/users/tabs_user.inc index 25dfee8c2..ecc70d05b 100644 --- a/plugins/admin/users/tabs_user.inc +++ b/plugins/admin/users/tabs_user.inc @@ -11,6 +11,7 @@ class usertabs extends tabs /* Add references/acls/snapshots */ $this->addSpecialTabs(); + } function save_object($save_current= FALSE) @@ -90,50 +91,9 @@ class usertabs extends tabs 'dn' to all plugins */ $baseobject= $this->by_object['user']; - /* Assemble cn */ - $pt= ""; - if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){ - if(!empty($baseobject->personalTitle)){ - $pt = $baseobject->personalTitle." "; - } - } - - if ($this->dn == 'new'){ - $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn; - $this->by_object['user']= $baseobject; - if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ - $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base; - } else { - $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base; - } - } // != 'new' - else - { - /* Extract cn and compare with actual cn present in 'dn' */ - if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ - $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base; - } else { - $new_dn= "cn=".$pt.$baseobject->givenName." ".$baseobject->sn.','. - get_people_ou().$baseobject->base; - } - - /* Hickert: 31.08.2005 - * fixed error = Trying to overwrite cn=*** which already exists. - * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn) - * the old_dn and new dn were different. cn=test ... cn=Test ... - * The following code decided to move the entry from old_dn to new_dn. (Because they differ) - * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with - * an error, because source and destination dn are both the same (for ldap, but not for php). - * This fix allow you to change the givenname or name attributes. - */ - if(strtolower($this->dn)==strtolower($new_dn)){ - $this->dn=$new_dn; - } - - if ($this->dn != $new_dn){ - - /* Write entry on new 'dn' */ - $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn; + if ($this->dn != 'new'){ + $new_dn= $baseobject->new_dn; + if (strtolower($this->dn) != strtolower($new_dn)){ /* Udpate acls */ $baseobject->update_acls($this->dn,$new_dn); @@ -142,11 +102,11 @@ class usertabs extends tabs /* Did we change ourselves? Update ui object. */ change_ui_dn($this->dn, $new_dn); - - /* Happen to use the new one */ - $this->dn= $new_dn; } } + + $this->dn= $baseobject->new_dn; + return tabs::save(); } diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index bb0607a3e..b02dc292d 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -24,6 +24,7 @@ class user extends plugin /* Plugin specific values */ var $base= ""; var $cn= ""; + var $new_dn= ""; var $personalTitle= ""; var $academicTitle= ""; var $homePostalAddress= ""; @@ -894,24 +895,17 @@ class user extends plugin } - /* Build new dn */ - if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ - $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base; - } else { - $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base; - } - /* This only gets called when user is renaming himself */ $ldap= $this->config->get_ldap_link(); - if ($this->dn != $new_dn){ + if ($this->dn != $this->new_dn){ /* Write entry on new 'dn' */ - $this->update_acls($this->dn,$new_dn); - $this->move($this->dn, $new_dn); + $this->update_acls($this->dn,$this->new_dn); + $this->move($this->dn, $this->new_dn); /* Happen to use the new one */ - change_ui_dn($this->dn, $new_dn); - $this->dn= $new_dn; + change_ui_dn($this->dn, $this->new_dn); + $this->dn= $this->new_dn; } @@ -1053,9 +1047,14 @@ class user extends plugin /* Permissions for that base? */ if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){ - $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base; + $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base; } else { - $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base; + /* Don't touch dn, if cn hasn't changed */ + if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn){ + $this->new_dn= $this->dn; + } else { + $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base); + } } /* Set the new acl base */ @@ -1086,10 +1085,8 @@ class user extends plugin $message[]= _("The required field 'Login' is not set."); } if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(cn=".$this->cn.")", array("uid")); - $ldap->fetch(); - if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){ + $ldap->cat($this->new_dn); + if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){ $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database."); } }