Code

Apply fix for #4099
authorpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 11 Feb 2010 12:34:19 +0000 (12:34 +0000)
committerpsc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 11 Feb 2010 12:34:19 +0000 (12:34 +0000)
- Add a new function getSambaSID() to groupGeneric which calculates
  a samba SID with the algorithm which is used for new groups as
  well.
- Remove the SID calculation code from the save function and just
  use getSambaSID
- In PrepareForCopyPaste determine a new SID for the new group
  object.

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@15611 594d385d-05f5-0310-b6e9-bd551577e9d8

trunk/gosa-core/plugins/admin/groups/class_groupGeneric.inc

index ce905299c035c620f612daa78c25b0e7602d3274..3956d560c270bf919cec075162dd251110c32d02 100644 (file)
@@ -881,6 +881,23 @@ class group extends plugin
 
   }
 
+  /*! \brief Get a new SambaSID for a group */
+  function getSambaSID()
+  {
+    $ldap = $this->config->get_ldap_link();
+    $gidNumber= $this->gidNumber;
+    while(TRUE){
+      $sid= $this->SID."-".($gidNumber*2 + $this->ridBase+1);
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(sambaSID=$sid)",array("sambaSID"));
+      if ($ldap->count() == 0){
+        break;
+      }
+      $gidNumber++;
+    }
+
+    return $sid;
+  }
 
   /* Save to LDAP */
   function save()
@@ -972,16 +989,7 @@ class group extends plugin
       if ($this->groupType == 0){
 
         if ($this->sambaSID == "" || $this->oldgroupType != $this->groupType){
-          $gidNumber= $this->gidNumber;
-          while(TRUE){
-            $sid= $this->SID."-".($gidNumber*2 + $this->ridBase+1);
-            $ldap->cd($this->config->current['BASE']);
-            $ldap->search("(sambaSID=$sid)",array("sambaSID"));
-            if ($ldap->count() == 0){
-              break;
-            }
-            $gidNumber++;
-          }
+          $sid = $this->getSambaSID();
           $this->attrs['sambaSID']= $sid;
           $this->sambaSID= $sid;
         }
@@ -1412,6 +1420,10 @@ class group extends plugin
         $this->$var = $source_o->$var;
     }
 
+    if ($this->smbgroup) {
+      $this->sambaSID = $this->getSambaSID();
+    }
+
     $this->memberUid = array();
     if(isset($source['memberUid'])){
       for($i = 0 ; $i < $source['memberUid']['count']; $i ++){