Code

Added RDN support for users
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Feb 2007 13:21:45 +0000 (13:21 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Feb 2007 13:21:45 +0000 (13:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5694 594d385d-05f5-0310-b6e9-bd551577e9d8

Changelog
TODO
plugins/admin/users/tabs_user.inc
plugins/personal/generic/class_user.inc

index d42c0ed4337234de6b98760c092c93d45ba79f84..21890a61da56770b7d75d795237902caa78395c2 100644 (file)
--- 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 169ce063bf586d3828d59a48f3e358aa70f9c488..5c965fbe278954ab7e8db9cd7ad6aa5b813dd6da 100644 (file)
--- a/TODO
+++ b/TODO
@@ -57,5 +57,3 @@ Target for 2.6:
 
 * Make IMAP namespace configurable
 
-* Try RDN style for unique names
-
index 9466dfb520b305375adbbf6652a0e62285f9e016..568ad9e544f9b2a08fc9aaec3536e19d0e211cff 100644 (file)
@@ -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();
   }
 
index 7559ebfc376c53021345ad0fddab6853e0523aff..7cdd417f34dbfb2bc6c39c6700b0e9f84528c7b9 100644 (file)
@@ -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.");
         }
       }