Code

Added Check that displays a warning if a duplicated uidNumber was written.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Feb 2008 13:25:34 +0000 (13:25 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Feb 2008 13:25:34 +0000 (13:25 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8931 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/posix/class_posixAccount.inc

index 0fb23e5a4878299eb059a653384abc093d59c738..04d61596fc2231e66ea1f3e17cf033f94f982bc4 100644 (file)
@@ -885,6 +885,18 @@ class posixAccount extends plugin
     /* Save data to LDAP */
     $ldap->cd($this->dn);
     $this->cleanup();
+    /* This is just a test, we have had duplicated ids 
+        in the past when copy & paste was used. 
+       Normaly this should not happen.
+     */ 
+    if(isset($this->attrs['uidNumber']) && !$this->force_ids){
+      $used = $this->get_used_uid_numbers();
+      if(isset($used[$this->attrs['uidNumber']]) && $used[$this->attrs['uidNumber']] != $this->dn){
+        msg_dialog::display(_("Uid number"),_("A duplicated uid number was written for this user, if this was not intended please verify all used uidNumbers."), WARNING_DIALOG);
+      }
+    }
+
     unset($this->attrs['uid']);
     $ldap->modify ($this->attrs); 
 
@@ -1222,6 +1234,22 @@ class posixAccount extends plugin
   }
 
 
+  function get_used_uid_numbers()
+  {
+    $ids= array();
+    $ldap= $this->config->get_ldap_link();
+
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search ("(&(objectClass=posixAccount)(uidNumber=*))", array("uidNumber"));
+
+    /* Get list of ids */
+    while ($attrs= $ldap->fetch()){
+      $ids[$attrs['uidNumber'][0]] = $attrs['dn'];
+    }
+    return($ids);
+  }
+
+  
   function get_next_id($attrib, $dn)
   {
     $ids= array();