Code

Updated functionality for postmodify and passwords
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 16 Jun 2005 11:49:57 +0000 (11:49 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 16 Jun 2005 11:49:57 +0000 (11:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@734 594d385d-05f5-0310-b6e9-bd551577e9d8

Changelog
include/class_password-methods.inc
include/class_plugin.inc
include/functions.inc
plugins/admin/ogroups/class_termgroup.inc
plugins/admin/systems/class_servGeneric.inc
plugins/admin/systems/class_terminalGeneric.inc
plugins/admin/systems/class_workstationGeneric.inc

index 659be4f5dccf3d8f8b1aa0d42a439d4245569026..5791711528d7d7b4738268c71b2e4a73cd2b4f98 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -16,6 +16,7 @@ GOsa2 changelog
     automatically if the revision changes
   - Improved W3C compatibility
   - Added checks that remove the contents of /var/spool/gosa/*
+  - Added postmodify for password change operations
 
 * gosa 2.4beta1
   - Override automatically detected user bases if they don't exist
index 52b862873f055ac079ad04b6119ab039eb50dbc4..cfa7b8aed8fdd830d42ab380c14e8bbac1d9dd91 100644 (file)
@@ -91,7 +91,6 @@ class passwordMethod
 // change_password, changes the Password, of the given dn
 function change_password ($dn, $password, $mode=0, $hash= "")
 {
-
   global $config;
   $newpass= "";
 
@@ -130,8 +129,6 @@ function change_password ($dn, $password, $mode=0, $hash= "")
     $newpass =  $test->generate_hash($password);
   }
 
-
-
   // Update shadow timestamp? 
   if (isset($attrs["shadowLastChange"][0])){
     $shadow= (int)(date("U") / 86400);
@@ -151,7 +148,7 @@ function change_password ($dn, $password, $mode=0, $hash= "")
     }
 
     // Create SMB Password 
-    $attrs =    generate_smb_nt_hash($password);
+    $attrs= generate_smb_nt_hash($password);
   }
 
   $attrs['userPassword']= array();
@@ -161,10 +158,27 @@ function change_password ($dn, $password, $mode=0, $hash= "")
   $ldap->modify($attrs);
 
 
-  if ($ldap->error != 'Success')
-  {
+  if ($ldap->error != 'Success') {
     print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."),
           $ldap->get_error()));
+  } else {
+
+    /* Find postmodify entries for this class */
+    $command= search_config($config->data['MENU'], "password", "POSTMODIFY");
+
+    if ($command != ""){
+      /* Walk through attribute list */
+      $command= preg_replace("/%userPassword/", $password, $command);
+      $command= preg_replace("/%dn/", $dn, $command);
+
+      if (check_command($command)){
+        @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
+        exec($command);
+      } else {
+        $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password");
+        print_red ($message);
+      }
+    }
   }
 }
 
index 2a50b4737782c01792e2158440346ecbfde2f531..e7c01c3aa12c827ffdf99a20c1e44280a7f813f6 100644 (file)
@@ -366,9 +366,9 @@ class plugin
   function postcreate()
   {
     /* Find postcreate entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTCREATE");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTCREATE");
     if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTCREATE");
+      $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTCREATE");
     }
 
     if ($command != ""){
@@ -392,9 +392,9 @@ class plugin
   function postmodify()
   {
     /* Find postcreate entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTMODIFY");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTMODIFY");
     if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTMODIFY");
+      $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTMODIFY");
     }
 
     if ($command != ""){
@@ -418,9 +418,9 @@ class plugin
   function postremove()
   {
     /* Find postremove entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTREMOVE");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTREMOVE");
     if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTREMOVE");
+      $command= search_config($this->config->data['SERVICE'], get_class($this), "POSTREMOVE");
     }
 
     if ($command != ""){
@@ -441,29 +441,6 @@ class plugin
     }
   }
 
-  function search($arr, $name, $return)
-  {
-    if (is_array($arr)){
-      foreach ($arr as $a){
-        if (isset($a['CLASS']) &&
-            strtolower($a['CLASS']) == strtolower($name)){
-
-          if (isset($a[$return])){
-            return ($a[$return]);
-          } else {
-            return ("");
-          }
-        } else {
-          $res= $this->search ($a, $name, $return);
-          if ($res != ""){
-            return $res;
-          }
-        }
-      }
-    }
-    return ("");
-  }
-
   /* Create unique DN */
   function create_unique_dn($attribute, $base)
   {
index 54ecb36a4bab180017c64c866d8b30947bd5bfb7..30c6d0529213ac92b77f40032ef024742d47e7e2 100644 (file)
@@ -1752,7 +1752,7 @@ function compare_revision($revision_file, $revision)
 }
 
 function progressbar($percentage,$width=100,$height=15,$showvalue=false)
-  {
+{
   $str = ""; // Our return value will be saved in this var
 
   $color  = dechex($percentage+150);
@@ -1766,30 +1766,54 @@ function progressbar($percentage,$width=100,$height=15,$showvalue=false)
 
   /* If theres a better solution for this, use it... */
   $str = "
-  <div style=\" width:".($width)."px; 
-                height:".($height)."px;
-                background-color:#000000;
-                padding:1px;\">
+    <div style=\" width:".($width)."px; 
+    height:".($height)."px;
+  background-color:#000000;
+padding:1px;\">
 
           <div style=\" width:".($width)."px;
-                        background-color:#$bgcolor;
-                        height:".($height)."px;\">
+        background-color:#$bgcolor;
+height:".($height)."px;\">
+
+         <div style=\" width:".$progress."px;
+height:".$height."px;
+       background-color:#".$color2.$color2.$color."; \">";
 
-                <div style=\" width:".$progress."px;
-                              height:".$height."px;
-                              background-color:#".$color2.$color2.$color."; \">";
 
+       if(($height >10)&&($showvalue)){
+         $str.=                 "<font style=\"font-size:".($height-2)."px;color:#FF0000;align:middle;padding-left:".((int)(($width*0.4)))."px;\">
+           <b>".$percentage."%</b>
+           </font>";
+       }
 
-    if(($height >10)&&($showvalue)){
-      $str.=                 "<font style=\"font-size:".($height-2)."px;color:#FF0000;align:middle;padding-left:".((int)(($width*0.4)))."px;\">
-                               <b>".$percentage."%</b>
-                             </font>";
-   }
+       $str.= "</div></div></div>";
+
+       return($str);
+}
 
-  $str.= "</div></div></div>";
 
-  return($str);
+function search_config($arr, $name, $return)
+{
+  if (is_array($arr)){
+    foreach ($arr as $a){
+      if (isset($a['CLASS']) &&
+          strtolower($a['CLASS']) == strtolower($name)){
+
+        if (isset($a[$return])){
+          return ($a[$return]);
+        } else {
+          return ("");
+        }
+      } else {
+        $res= search_config ($a, $name, $return);
+        if ($res != ""){
+          return $res;
+        }
+      }
+    }
   }
+  return ("");
+}
 
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 01d0e0d975ec81cdbe234f87c430cede26a4c17f..76b54705a8f2c8a19d061719e5ae177be44759e1 100644 (file)
@@ -50,7 +50,7 @@ class termgroup extends plugin
 
       switch($_POST['saction']){
         case 'wake':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "WAKECMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
           if ($cmd == ""){
             print_red(_("No WAKECMD definition found in your gosa.conf"));
           } else {
@@ -62,7 +62,7 @@ class termgroup extends plugin
           break;
 
         case 'reboot':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "REBOOTCMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
           if ($cmd == ""){
             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
           } else {
@@ -74,7 +74,7 @@ class termgroup extends plugin
           break;
 
         case 'halt':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "HALTCMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
           if ($cmd == ""){
             print_red(_("No HALTCMD definition found in your gosa.conf"));
           } else {
index 12c1c309dc3be2ddb7b9c2333fd92a30ec828883..ee9c214a051989bcca1e8667e8d0b15061402e6c 100644 (file)
@@ -54,7 +54,7 @@ class servgeneric extends plugin
     if (isset($_POST['action'])){
       switch($_POST['action']){
         case 'wake':
-          $cmd= $this->search($this->config->data['TABS'], "servgeneric", "WAKECMD");
+          $cmd= search_config($this->config->data['TABS'], "servgeneric", "WAKECMD");
           if ($cmd == ""){
             print_red(_("No WAKECMD definition found in your gosa.conf"));
           } else {
@@ -66,7 +66,7 @@ class servgeneric extends plugin
           break;
 
         case 'reboot':
-          $cmd= $this->search($this->config->data['TABS'], "servgeneric", "REBOOTCMD");
+          $cmd= search_config($this->config->data['TABS'], "servgeneric", "REBOOTCMD");
           if ($cmd == ""){
             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
           } else {
@@ -78,7 +78,7 @@ class servgeneric extends plugin
           break;
 
         case 'halt':
-          $cmd= $this->search($this->config->data['TABS'], "servgeneric", "HALTCMD");
+          $cmd= search_config($this->config->data['TABS'], "servgeneric", "HALTCMD");
           if ($cmd == ""){
             print_red(_("No HALTCMD definition found in your gosa.conf"));
           } else {
index e639e1636edd26b1e43af4aaeaaf694b8c976e2a..f95685e7ece1f1804c5ab224b1100556c7d06dc1 100644 (file)
@@ -84,7 +84,7 @@ class termgeneric extends plugin
     if (isset($_POST['action'])){
       switch($_POST['saction']){
         case 'wake':
-          $cmd= $this->search($this->config->data['TABS'], "termgeneric", "WAKECMD");
+          $cmd= search_config($this->config->data['TABS'], "termgeneric", "WAKECMD");
           if ($cmd == ""){
             print_red(_("No WAKECMD definition found in your gosa.conf"));
           } else {
@@ -96,7 +96,7 @@ class termgeneric extends plugin
           break;
 
         case 'reboot':
-          $cmd= $this->search($this->config->data['TABS'], "termgeneric", "REBOOTCMD");
+          $cmd= search_config($this->config->data['TABS'], "termgeneric", "REBOOTCMD");
           if ($cmd == ""){
             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
           } else {
@@ -108,7 +108,7 @@ class termgeneric extends plugin
           break;
 
         case 'halt':
-          $cmd= $this->search($this->config->data['TABS'], "termgeneric", "HALTCMD");
+          $cmd= search_config($this->config->data['TABS'], "termgeneric", "HALTCMD");
           if ($cmd == ""){
             print_red(_("No HALTCMD definition found in your gosa.conf"));
           } else {
index 1a82a1ae0eed1a97b969a3fbce78eb4ef2fdbc8b..1b8775eced24032bf4e6891375fead677ad28722 100644 (file)
@@ -93,7 +93,7 @@ class workgeneric extends plugin
     if (isset($_POST['action'])){
       switch($_POST['saction']){
         case 'wake':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "WAKECMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "WAKECMD");
           if ($cmd == ""){
             print_red(_("No WAKECMD definition found in your gosa.conf"));
           } else {
@@ -105,7 +105,7 @@ class workgeneric extends plugin
           break;
 
         case 'reboot':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "REBOOTCMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "REBOOTCMD");
           if ($cmd == ""){
             print_red(_("No REBOOTCMD definition found in your gosa.conf"));
           } else {
@@ -117,7 +117,7 @@ class workgeneric extends plugin
           break;
 
         case 'halt':
-          $cmd= $this->search($this->config->data['TABS'], "terminfo", "HALTCMD");
+          $cmd= search_config($this->config->data['TABS'], "terminfo", "HALTCMD");
           if ($cmd == ""){
             print_red(_("No HALTCMD definition found in your gosa.conf"));
           } else {