Code

Added fall back to old style move method.
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 76c3e7c25c002856e7ac1770cbf41e4f90b4ecde..fcccd5843bb22ea457bd8fca0aeb3de6e6b6b18b 100644 (file)
@@ -129,8 +129,16 @@ class gosaSupportDaemon
   public function get_error()
   {
     $str = $this->s_error;
-    $str = preg_replace("/ /"," ",$str);
-    return($str);
+    $ret = "";
+    if(is_string($str)){
+      $ret = $str;
+    }else{
+      foreach($str as $msg){
+        $ret .= $msg." ";
+      }
+    }
+    $ret = preg_replace("/ /"," ",$ret);
+    return($ret);
   }
 
 
@@ -869,6 +877,7 @@ class gosaSupportDaemon
 
     $attr = "";
     foreach($data as $key => $value){
+      $key = strtolower($key);
       if(is_array($value)){
         foreach($value as $sub_value){
           $attr.= "<$key>".strtolower($sub_value)."</$key>\n";
@@ -1275,7 +1284,12 @@ class gosaSupportDaemon
       "<target>".$server."</target>".
       "</xml>";
 
-    return($this->_send($xml_msg,TRUE));
+    $res = $this->_send($xml_msg,TRUE);
+    if(isset($res['XML'])){
+      return($res['XML']);
+    }else{
+      return($ret);
+    }
   }
 
 
@@ -1313,6 +1327,7 @@ class gosaSupportDaemon
         trigger_error("Invalid configuration attribute given '".$key."=".$value."'.");
         return($ret);
       }
+      $key = strtolower($key);
       if(is_array($value)){
         foreach($value as $val){
           $attrs.= "<$key>$val</$key>\n";
@@ -1371,6 +1386,7 @@ class gosaSupportDaemon
         trigger_error("Invalid configuration attribute given '".$key."=".$value."'.");
         return($ret);
       }
+      $key = strtolower($key);
       if(is_array($value)){
         foreach($value as $val){
           $attrs.= "<$key>$val</$key>\n";
@@ -1384,7 +1400,7 @@ class gosaSupportDaemon
      */ 
     $xml_msg = 
       "<xml>".
-      "<header>gosa_krb5_set_principal</header>".
+      "<header>gosa_krb5_modify_principal</header>".
       "<principal>".$name."</principal>".
       $attrs.
       "<source>GOSA</source>".
@@ -1564,6 +1580,7 @@ class gosaSupportDaemon
         trigger_error("Invalid policy configuration attribute given '".$id."=".$value."'.");
         return($ret);
       }
+      $id = strtolower($id);
       $attrs.= "<$id>$value</$id>\n";
     }
 
@@ -1619,6 +1636,7 @@ class gosaSupportDaemon
         trigger_error("Invalid policy configuration attribute given '".$id."=".$value."'.");
         return($ret);
       }
+      $id = strtolower($id);
       $attrs.= "<$id>$value</$id>\n";
     }
 
@@ -1672,6 +1690,45 @@ class gosaSupportDaemon
   }
 
 
+  /*! \brief  Sets the password of for the given principal.
+              (Uses the GOsa support daemon instead of the ldap database.)
+      @param  String  The servers mac
+      @param  String  The principals name
+      @param  String  $the new password.   
+      @return Boolean  TRUE on success else FALSE
+   */
+  public function krb5_set_password($server,$name,$password)
+  {
+    $ret = FALSE;
+
+    /* Check if the given server is a valid mac address
+     */
+    if(!tests::is_mac($server)){
+      trigger_error("The given server address '".$server."' is invalid, it must be a valid mac address");
+      return($ret);
+    }
+
+    /* Check if the given name is a valid request value
+     */
+    if(!is_string($name) || empty($name)){
+      trigger_error("The given principal name is not of type string or it is empty.");
+      return($ret);
+    }
+
+    /* Prepare request event
+     */
+    $xml_msg =
+      "<xml>".
+      "<header>gosa_krb5_set_password</header>".
+      "<principal>".$name."</principal>".
+      "<password>".$password."</password>".
+      "<source>GOSA</source>".
+      "<target>".$server."</target>".
+      "</xml>";
+    return($this->_send($xml_msg,TRUE) == TRUE && !$this->is_error());
+  }
+
+
   /*! \brief  Returns log file informations for a given mac address 
       @param  $mac The mac address to fetch logs for.
       @retrun Array A Multidimensional array containing log infos.