Code

Added rid/sid check
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 May 2007 13:58:53 +0000 (13:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 May 2007 13:58:53 +0000 (13:58 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6236 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep_Config2.inc
setup/setup_config2.tpl

index 8eab8885f68696eb644f538ff0bad3ff01c94abf..408b2f828f05ed66f79fd6e472a513d7363e42c9 100644 (file)
@@ -47,7 +47,11 @@ class Step_Config2 extends setup_step
                                   "smbhash"          => 'SMBHASH',
                                   "samba_rid_active" => FALSE); 
 
+  var $sambaDomain_found = FALSE;
+
   var $attributes = array("governmentmode","sambaidmapping","cyrusunixstyle","mail");
+  var $called = FALSE;
+
 
   function Step_Config2()
   {
@@ -80,6 +84,31 @@ class Step_Config2 extends setup_step
  
   function execute()
   {
+    /* On first call check for rid/sid base */
+    $cv = $this->parent->captured_values;
+    $ldap = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap->cd($cv['base']);
+    $ldap->search("(objectClass=sambaDomain)",array("dn"));
+    if($ldap->count()){
+      $this->sambaDomain_found =TRUE;
+    }else{
+      $this->sambaDomain_found =FALSE;
+    }
+
+    if(!$this->called){
+      if(!$this->sambaDomain_found){
+        $this->samba_settings['samba_sid_active'] = TRUE;
+        $this->samba_settings['samba_rid_active'] = TRUE;
+      }
+   
+      $this->called = TRUE;
+    }
+
     /* Update snapshot values, with already collected values */
     foreach($this->generic_settings as $key => $value){
       foreach(array("snapshot_base","snapshot_user","snapshot_server") as $attr){
@@ -92,6 +121,7 @@ class Step_Config2 extends setup_step
     }
 
     $smarty = get_smarty();
+    $smarty->assign("sambaDomain_found",$this->sambaDomain_found);
     $smarty->assign("generic_settings",$this->generic_settings);
     $smarty->assign("mail_settings",$this->mail_settings);
     $smarty->assign("mail_methods",$this->mail_methods);
@@ -176,6 +206,10 @@ class Step_Config2 extends setup_step
         $this->samba_settings['smbhash'] = $_POST['smbhash'];
       }
 
+      if(!$this->sambaDomain_found){
+        $this->samba_settings['samba_sid_active'] = TRUE;
+        $this->samba_settings['samba_rid_active'] = TRUE;
+      }
     }
 
     $tmp = $this->check();
index 679fee9a273c2eb6d471c7ed93cd20a0f8cd2a1d..5b35c4ecb0c9fca889a0bfe497a9bdcd63bb3ecb 100644 (file)
@@ -20,7 +20,7 @@
                     onClick='changeState("samba_sid");'>
                 <input size=20 id='samba_sid' name='samba_sid' type='text' value='{$samba_settings.samba_sid}' disabled>
             {else}
-                <input type='checkbox' value='1' name='samba_sid_active' checked>
+                <input type='checkbox' value='1' name='samba_sid_active' checked {if !$sambaDomain_found} disabled {/if}>
                 <input size=20 id='samba_sid' name='samba_sid' type='text' value='{$samba_settings.samba_sid}'  >
             {/if}
         </div>
@@ -36,7 +36,7 @@
                     onClick='changeState("samba_rid");'>
                 <input size=20 id='samba_rid' name='samba_rid' type='text' value='{$samba_settings.samba_rid}' disabled>
             {else}
-                <input type='checkbox' value='1' name='samba_rid_active' checked>
+                <input type='checkbox' value='1' name='samba_rid_active' checked {if !$sambaDomain_found} disabled {/if}>
                 <input size=20 id='samba_rid' name='samba_rid' type='text' value='{$samba_settings.samba_rid}'  >
             {/if}
         </div>