From dfa5fe6c803668ad23a8c44b6412f5d54d6d64b5 Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 6 Feb 2007 13:21:45 +0000 Subject: [PATCH] Added RDN support for users git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5694 594d385d-05f5-0310-b6e9-bd551577e9d8 --- Changelog | 3 ++ TODO | 2 - plugins/admin/users/tabs_user.inc | 52 +++---------------------- plugins/personal/generic/class_user.inc | 37 ++++++++---------- 4 files changed, 26 insertions(+), 68 deletions(-) diff --git a/Changelog b/Changelog index d42c0ed43..21890a61d 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,9 @@ GOsa2 changelog * gosa 2.5.9 - Fixed ldap tls connections when schema check was being used - Updated italian translation + - Added the possiblility to choose a RDN style for DN's when + a CN is already in use + - Fixed a problem with cut'n paste for groups and ogroups * gosa 2.5.8 - Fixed problem with winstations shown in user list. diff --git a/TODO b/TODO index 169ce063b..5c965fbe2 100644 --- a/TODO +++ b/TODO @@ -57,5 +57,3 @@ Target for 2.6: * Make IMAP namespace configurable -* Try RDN style for unique names - diff --git a/plugins/admin/users/tabs_user.inc b/plugins/admin/users/tabs_user.inc index 9466dfb52..568ad9e54 100644 --- a/plugins/admin/users/tabs_user.inc +++ b/plugins/admin/users/tabs_user.inc @@ -85,60 +85,20 @@ 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){ + if ($this->dn != 'new'){ + $new_dn= $baseobject->new_dn; + if (strtolower($this->dn) != strtolower($new_dn)){ - /* Write entry on new 'dn' */ - $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn; $baseobject->move($this->dn, $new_dn); $this->by_object['user']= $baseobject; /* 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 7559ebfc3..7cdd417f3 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -19,6 +19,7 @@ class user extends plugin /* Plugin specific values */ var $base= ""; var $cn= ""; + var $new_dn= ""; var $personalTitle= ""; var $academicTitle= ""; var $homePostalAddress= ""; @@ -845,23 +846,16 @@ class user extends plugin $this->attrs["jpegPhoto"] = array(); } - /* 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->move($this->dn, $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; } @@ -1005,17 +999,22 @@ 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); + } } $ui= get_userinfo(); - $acl= get_permissions ($new_dn, $ui->subtreeACL); - $acl= get_module_permission($acl, "user", $new_dn); + $acl= get_permissions ($this->new_dn, $ui->subtreeACL); + $acl= get_module_permission($acl, "user", $this->new_dn); if ($this->dn == "new" && chkacl($acl, "create") != ""){ $message[]= _("You have no permissions to create a user on this 'Base'."); - } elseif ($this->dn != $new_dn && $this->dn != "new"){ + } elseif ($this->dn != $this->new_dn && $this->dn != "new"){ $acl= get_permissions ($this->dn, $ui->subtreeACL); $acl= get_module_permission($acl, "user", $this->dn); if (chkacl($acl, "create") != ""){ @@ -1046,10 +1045,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."); } } -- 2.30.2